public static void Zip(string output, FileCollection files, MemoryFileCollection memoryFiles) { System.IO.DirectoryInfo directoryInfo = new System.IO.FileInfo(output).Directory; if (!directoryInfo.Exists) { directoryInfo.Create(); } using (System.IO.FileStream fileStream = System.IO.File.Create(output)) { NZlib.Zip.ZipOutputStream zipOutputStream = new NZlib.Zip.ZipOutputStream(fileStream); zipOutputStream.SetLevel(ZIP_LEVEL); //Files foreach (File file in files) { AddFile(zipOutputStream, file); } //MemoryFiles foreach (MemoryFile memoryFile in memoryFiles) { Add(zipOutputStream, memoryFile.Name, memoryFile.DateTime, memoryFile.Bytes.Length, memoryFile.Bytes); } zipOutputStream.Finish(); zipOutputStream.Close(); fileStream.Close(); } }
public static void Zip(string output, FileCollection files) { MemoryFileCollection memoryFiles = new MemoryFileCollection(); Zip(output, files, memoryFiles); }