ZipHelper
public class ZipHelper { public static void ZipFile(string strFile, string strZip) { if (strFile[strFile.Length – 1] != Path.DirectorySeparatorChar) strFile += Path.DirectorySeparatorChar; ZipOutputStream s = new ZipOutputStream(File.Create(strZip)); s.SetLevel(6); zip(strFile, s, strFile); s.Finish(); s.Close(); } private static void zip(string strFile, ZipOutputStream s, string staticFile) { if (strFile[strFile.Length – 1] != Path.DirectorySeparatorChar) strFile += Path.DirectorySeparatorChar; Crc32 crc = new Crc32(); string[] filenames = Directory.GetFileSystemEntries(strFile); foreach (string file in filenames) { if (Directory.Exists(file)) { zip(file, s, staticFile); } else // 否则直接压缩文件 { //打开压缩文件 FileStream fs = File.OpenRead(file); byte[] buffer = new byte[fs.Length]; fs.Read(buffer,
继续阅读