tags:

views:

127

answers:

4

Hi all

Yes, I know GZipStream or DeflateStream is the common ones in .NET Framework which handle compression/decompression.

I wish to have compress/decompress functions in my program, but

  1. I wish a .NET Framework C# one, not a 3rd party open source. I can't use because of those copyright restrictions in my program.

  2. GZipStream and DeflateStream are not so good. for e.g., GZipStream compress a file to 480KB while 7Zip compress the same file to the size of 57KB.

Does Microsoft have other good compression methods???

Thanks

+3  A: 

GZipStream and DeflateStream are specifically intended for compressed streams, not general compression of files for storage.

Other than those classes, compression is not built into .NET. If you want high-quality compression you will have to go to a third party library. Check out http://www.7-zip.org/sdk.html for an open-source 7zip library.

Dave Swersky
The web page states that "LZMA SDK is placed in the public domain" that should mean that it is free to use however you like, doesn´t it?
Jens Granlund
Dave put it in the right direction, but Stefan gave the link to the ready to use .Net implementation of the 7zip algorithm (which is lzma).
Oliver
Absolutely, free to all. The OP says he doesn't want "3rd party open source." If cost is not the concern, I'm not sure what is.
Dave Swersky
+2  A: 

I don't have any statistics regarding compression rates, but I'd been using the SharpZipLib library for years with much success.

Cocowalla
+2  A: 

There is a managed wrapper for 7zip. The license is LGPL so you can use it in closed source projects. I do not know if this fits your license requirements as you did not state them.

http://sevenzipsharp.codeplex.com/

Stefan Egli
A: 

you can also use the open source ZLib (http://www.zlib.net/) with PInvoke, or use a wrapper for it (I've used zlib.net - http://www.componentace.com/zlib_.NET.htm - but I believe it had some bugs). it's less convenient than managed libraries, but more efficient than DeflateStream/GZipStream (which are the same except for an extra CRC in GZipStream).

Yonatan Karni