Ejemplo n.º 1
0
 public static void AppendAllLines(string path, IEnumerable <string> contents, Encoding encoding = null)
 {
     DirectoryExtension.Create(path);
     if (encoding is null)
     {
         File.AppendAllLines(path, contents);
     }
     else
     {
         File.AppendAllLines(path, contents, encoding);
     }
 }
Ejemplo n.º 2
0
 public static void AppendAllText(string path, string contents, Encoding encoding = null)
 {
     DirectoryExtension.Create(path);
     if (encoding is null)
     {
         File.AppendAllText(path, contents);
     }
     else
     {
         File.AppendAllText(path, contents, encoding);
     }
 }
Ejemplo n.º 3
0
 public static FileStream Create(string path, int?bufferSize = null, FileOptions?options = null)
 {
     DirectoryExtension.Create(path);
     if (options != null && bufferSize != null)
     {
         return(File.Create(path, (int)bufferSize, (FileOptions)options));
     }
     if (bufferSize != null)
     {
         return(File.Create(path, (int)bufferSize));
     }
     return(File.Create(path));
 }
Ejemplo n.º 4
0
 public static void Move(string sourceFileName, string destFileName, bool overwrite = false)
 {
     if (!File.Exists(sourceFileName))
     {
         return;
     }
     DirectoryExtension.Create(destFileName);
     if (!overwrite && File.Exists(destFileName))
     {
         return;
     }
     if (File.Exists(destFileName))
     {
         File.Delete(destFileName);
     }
     File.Move(sourceFileName, destFileName);
 }
Ejemplo n.º 5
0
 public static bool Copy(string sourceFileName, string destFileName, bool overwrite = false)
 {
     if (!File.Exists(sourceFileName))
     {
         return(false);
     }
     DirectoryExtension.Create(destFileName);
     try
     {
         File.Copy(sourceFileName, destFileName, overwrite);
         return(true);
     }
     catch
     {
         return(false);
     }
 }