zoukankan      html  css  js  c++  java
  • C# .NET 使用第三方类库DotNetZip解压/压缩Zip文件

    dotNetZip on CodePlex: http://dotnetzip.codeplex.com/

    详细的可以看源代码……总之感觉比SharpZipLib好用。而且DotNetZip支持VB,C#以及任何.NET语言。

    加压:(从CodePlex上偷过来的)

    using (ZipFile zip = new ZipFile())
     {
         // add this map file into the "images" directory in the zip archive 把这个PNG文件添加到zip档案的"images"目录下
         zip.AddFile("c:\images\personal\7440-N49th.png", "images");
         // add the report into a different directory in the archive 然后把PDF文件添加到zip档案的"files"目录下,把ReadMe.txt放到根目录
         zip.AddFile("c:\Reports\2008-Regional-Sales-Report.pdf", "files");
         zip.AddFile("ReadMe.txt");
       // 把zip档案保存为MyZipFile.zip
         zip.Save("MyZipFile.zip");
     }

    解压更简单:

    using (ZipFile zip = new ZipFile("MyZipFile.zip"))
    {
      zip.ExtractAll("c:\myfolder", ExtractExistingFileAction.OverwriteSilently);
    }

    这就可以了!什么问题都木有,是不是比SharpZipLib方便多了!

  • 相关阅读:
    docker 常用
    vue-cli 的静态资源
    ubuntu 恢复模式
    virtualbox
    cmake 使用技巧
    VLC播放pcm
    Ice-Lite 理解
    webrtc ice流程
    Mediasoup_Demo信令过程, client and server
    Mediasoup
  • 原文地址:https://www.cnblogs.com/damsoft/p/6100320.html
Copyright © 2011-2022 走看看