public static void CompressDirectory(string directoryPath, string archivePath, string archiveName, bool deleteDirectory=false) { string archivefile = Path.Combine(archivePath, archiveName); Directory.CreateDirectory(archivePath); string[] files = Directory.GetFiles(directoryPath); using (var def = new UZipDotNet.DeflateZipFile(@archivefile)) { foreach (string file in files) { string fileName = Path.GetFileName(file); def.Compress(file, fileName); } def.Save(); } if(deleteDirectory) Directory.Delete(directoryPath, true); }
public static void CompressDirectory(string directoryPath, string archivePath, string archiveName, bool deleteDirectory = false) { string archivefile = Path.Combine(archivePath, archiveName); Directory.CreateDirectory(archivePath); string[] files = Directory.GetFiles(directoryPath); using (var def = new UZipDotNet.DeflateZipFile(@archivefile)) { foreach (string file in files) { string fileName = Path.GetFileName(file); def.Compress(file, fileName); } def.Save(); } if (deleteDirectory) { Directory.Delete(directoryPath, true); } }