zoukankan      html  css  js  c++  java
  • asp.net压缩,解压缩

    首先 需要下载DotNetZip的组件

    http://dotnetzip.codeplex.com/

    在项目中引入Ionic.Zip

    引入名字空间

    using System.Text;
    using Ionic.Zip;

    压缩

    public static void zipDir(string source,string target)
            {
                //source d:test
                //target d:/mytest.zip
                using (ZipFile zip = new ZipFile(Encoding.UTF8))
                {
                    zip.AddDirectory(source);
                    zip.Save(target);
                }
            }

    解压缩

    public static void enZip(string source, string target)
            {
                //source "d:/Archive.zip"  target"d:/newtest"
                using (ZipFile zip = ZipFile.Read(source))
               {
                    zip.ExtractAll(target);
                }
            }

     要使用密码的话 zip.Password = "123456";

  • 相关阅读:
    观光公交
    luogu 4779 【模板】
    最小生成树(luogu 3366)
    计算系数
    更新区间,求单点—— luogu 3368
    HDU
    HDU
    HDU
    HDU
    BFS
  • 原文地址:https://www.cnblogs.com/mengxingxinqing/p/3081451.html
Copyright © 2011-2022 走看看