Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open-source zip library for .NET? [closed]

Does anyone know of a good open-source zipping library for .NET?

like image 523
fARcRY Avatar asked Dec 17 '08 12:12

fARcRY


2 Answers

SharpZipLib

Regarding the comments and other posts about the internal gzip implementation, they are not the same! GZip does not create the header required for archiving; it is only useful for "zipping" one file or stream.

Proper zip archives contain a header that list all compressed files and where in the compressed data they come and therefore you need something that makes a header. That means SharpZipLib, one of the many commercial versions or using something external with .NET bindings like 7zip.

Just on the offchance somebody wants to say this: "But I see .gz files in Linux all the time!" - they're just single files and .tar.gz is no exception - tar is the archive file. The .gz is that archive compressed.

like image 88
Oli Avatar answered Sep 19 '22 21:09

Oli


Couple comments.

  1. Don't use the J# runtime. J# has been discontinued by Microsoft. Future support is questionable. Also, the entire J# runtime is a big nut to swallow when all you want is ZIP support.
  2. The GzipStream in System.IO.Compression, part of the .NET base class library since .NET 2.0, provides a stream interface for IETF RFC-1952 compression. It is ok for compression, though the compression ratio is not optimal and it will significantly expand data that has been previously compressed. This bug was reported to Microsoft, but it's apparently been closed. There is also a DeflateStream which is similar, but for RFC 1951. There's a common misconception that GZipStream does zip files. Not true. Neither of these two do zip files.
  3. There's System.IO.Packaging.ZipPackage. It works, but is designed and intended primarily for packaging of MS Office 2007 (.docx, .xslx, and .pptx) files. It's unwieldy for zip files and doesn't support lots of ZIP features, like encryption.
  4. If you want a flexible way to create and read zip files in .NET you need a 3rd party library, currently.

DotNetZip is a good 3rd party option. Free, open source, actively maintained, simple to use, small, good feature set. It is shipped as a single assembly - it is fully managed code. Works on Compact Framework as well as on the regular .NET Framework. The pre-req is .NET 2.0.

DotNetZip also includes a ZLIB library, with classes like {Zlib,GZip,Deflate}Stream. They are comparable to those built-in to .NET, but they include the ability to set Compression Levels, and at higher levels they compress much more effectively than the built-in classes. The ZlibStream does RFC 1950 compression.

DotNetZip does ZIP64, passwords, AES encryption, streams, SFX, and Unicode. Everyone who uses it says it is much simpler to use than SharpZipLib. There's a good help file (.chm) and lots of code examples.

DNZ CHM

like image 25
Cheeso Avatar answered Sep 20 '22 21:09

Cheeso