public static void MoveFromPathToPath(string sourceDirName, string destDirName) { if (ValidationSchema.IsDirectory(sourceDirName)) { Directory.Move(sourceDirName, destDirName); } else { File.Move(sourceDirName, destDirName); } }
public static void Delete(string sourceDirName) { if (ValidationSchema.IsDirectory(sourceDirName)) { Directory.Delete(sourceDirName); } else { File.Delete(sourceDirName); } }
public static void Copy(string sourceDirName, string destDirName) { if (ValidationSchema.IsDirectory(sourceDirName)) { throw new Exception(Exceptions.CannotCopyFolderError); } else { File.Copy(sourceDirName, destDirName); } }
public static void Zip(string sourceDirName, string compressTo) { if (ValidationSchema.IsDirectory(sourceDirName)) { throw new Exception(Exceptions.ArchiveError); } else { using (FileStream sourceStream = new FileStream(sourceDirName, FileMode.OpenOrCreate)) { using (FileStream targetStream = File.Create(compressTo)) { using (GZipStream compressionStream = new GZipStream(targetStream, CompressionMode.Compress)) { sourceStream.CopyTo(compressionStream); MessageBox.Show(String.Format("Файл был заархивирован в {0}", compressTo)); } } } } }