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:DemoZip1.png", "images"); // add the report into a different directory in the archive 将报告添加到归档中的其他目录中 zip.AddFile(@"E:DemoZip2.txt", "files"); // 添加到根目录 zip.AddFile(@"E:DemoZip3.txt"); // 添加到根目录,并重命名 zip.AddFile(@"E:DemoZip4.txt").FileName = "5.txt"; zip.Save(@"E:DemoZipipFile.zip"); } //2.解压 //指定编码,防止存在中文乱码情况 //如情况:路径中具有非法字符 using (ZipFile zip = new ZipFile(@"E:DemoZipipFile.zip", System.Text.Encoding.UTF8)) { zip.ExtractAll(@"E:DemoZipipFileFolder", ExtractExistingFileAction.OverwriteSilently); }