zoukankan      html  css  js  c++  java
  • 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: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);
                }
  • 相关阅读:
    hibernate03增删改查
    hibernate02环境的搭建
    hibernate01ORM的引入
    20170623_oracle_优化与体系结构
    20170626_oracle_数据库设计
    logging模块
    hashlib模块
    json和pickle模块
    sys模块
    os模块
  • 原文地址:https://www.cnblogs.com/ChenRihe/p/DotNetZip.html
Copyright © 2011-2022 走看看