dotNetZip on CodePlex: http://dotnetzip.codeplex.com/
壓縮/解壓/重命名:
//1.壓縮 //指定編碼,防止中文亂碼情況 using (ZipFile zip = new ZipFile(System.Text.Encoding.UTF8)) { // add this map file into the "images" directory in the zip archive 將該地圖文件添加到zip存檔中的“images”目錄中 zip.AddFile(@"E:\DemoZip\1.png", "images"); // add the report into a different directory in the archive 將報告添加到歸檔中的其他目錄中 zip.AddFile(@"E:\DemoZip\2.txt", "files"); // 添加到根目錄 zip.AddFile(@"E:\DemoZip\3.txt"); // 添加到根目錄,並重命名 zip.AddFile(@"E:\DemoZip\4.txt").FileName = "5.txt"; zip.Save(@"E:\DemoZip\ZipFile.zip"); } //2.解壓 //指定編碼,防止存在中文亂碼情況 //如情況:路徑中具有非法字符 using (ZipFile zip = new ZipFile(@"E:\DemoZip\ZipFile.zip", System.Text.Encoding.UTF8)) { zip.ExtractAll(@"E:\DemoZip\ZipFileFolder", ExtractExistingFileAction.OverwriteSilently); }