C# .NET 使用DotNetZip开源类库 处理 压缩/解压 Zip 处理乱码情况

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);
            }