public static void Move(string source, string dest) { try { DirectoriesManager.Create(Path.GetDirectoryName(dest)); File.Move(source, dest); } catch (Exception ex) { throw ex; } }
public static bool IsDirectoryWritable(string directoryPath, bool throwOnFail = false) { try { DirectoriesManager.Create(directoryPath); var path = Path.Combine(directoryPath, Path.GetRandomFileName()); using (var fileStream = File.Create(path, 1, FileOptions.DeleteOnClose)) { } return(true); } catch (UnauthorizedAccessException) { if (throwOnFail) { throw; } return(false); } }
public static void Copy(string sourcePath, string destinationPath, bool overwrite = true) { DirectoriesManager.Create(PathsManager.GetDirectoryPath(destinationPath)); File.Copy(sourcePath, destinationPath, overwrite); }