Is there a built-in zip library in .NET 3.5?

混江龙づ霸主 提交于 2019-11-27 05:32:27

问题


Is there a built-in zip library in .NET 3.5?

If not, what are the popular open source .net zip libraries.


回答1:


There is no built-in library. There are open-source options.

DotNetZip is one. Simple, easy to use. It has good features: AES Encryption, regular encryption, streams, ZIP64, file comments, Unicode, progress events, more. And it's free and open source.

Here's some sample code.

    // extract all Photoshop files larger than 100mb
    using (ZipFile zip1 = ZipFile.Read(ZipFileName))
    {
        var LargePhotoShopFiles = zip1.SelectEntries("name = *.psd  and size > 100mb");
        foreach (ZipEntry e in LargePhotoShopFiles)
        {
            if (e.UsesEncryption)
                e.ExtractWithPassword("unpackDirectory", "VerySecret!");
            else 
                e.Extract("unpackDirectory");
        }
    }



回答2:


EDIT: See note in comments - SharpZipLib is now unmaintained, and you probably want to avoid it.

Open source: #ZipLib

I believe that the classes in the System.IO.Compression namespace are fine for compressing/decompressing a single stream of data, but there's nothing built into the framework to cope with actual zip files.

EDIT: As noted in Ants' answer, there's System.IO.Packaging.ZipPackage but it certainly looks like that's really designed for use in WPF, and wouldn't be terribly convenient to use for general zip file handling. Worth looking into though. I wasn't aware of it before though... definitely worth investigating.




回答3:


Check out System.IO.Packaging.ZipPackage class.




回答4:


7Zip will help and its available in multiple languages




回答5:


http://www.icsharpcode.net/OpenSource/SharpZipLib/




回答6:


Try System.IO.Compression.DeflateStream.




回答7:


I will be second to recommend http://www.7-zip.org/sdk.html LZMA SDK, but it's not ZIP.

  1. It's in public domain
  2. It's FAST on decompression
  3. It has fully managed implementation
  4. It's much better compressing than ZIP/RAR
  5. It has very small footprint
  6. It can work as a stream



回答8:


System.IO.Compression has ZipArchive class as of .Net 4.5.



来源:https://stackoverflow.com/questions/593026/is-there-a-built-in-zip-library-in-net-3-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!