1

File compression is a very important matter now a days. I am a C# programmer. I heard about DotNetZip, SharpZibLib, GZipStream etc. Confused about which one is the best. What I need are:

1: Faster compression speed

2: Better encryption

3: Both zip, unzip facility

4: Password protection

5: Free and enough reference/tutorial

6: Easier for beginner

7: Add files having .mp3, .txt etc format

8: Can work with many files(say 500 at a time, total 1/2 GB)

Thanks in advance

Update: Time is more more expensive than space :)

whoone
  • 533
  • 3
  • 7
  • 16
  • or it is farter the compression process or is better the cmpression level, you have to decide what you want –  Dec 09 '12 at 15:12
  • 3
    Nothing is really good for .mp3, .3gp and mp4, because these formats are already compressed. And I don't think these criteria really fit.. Rather just start and identify potential bottle necks when it matters. – JustAnotherUser Dec 09 '12 at 15:17

2 Answers2

3

I have used DotNetZip in some projects and it supports all the things you want. Considering the speed, you have to choose between speed a compression, thats just how zip works. The library provides an option for you to choose whant compression level you want.

The library is well documented and really easy for beginners. Starting with it is just about installing 1 nuget package and calling zipFile.AddFile and zipFile.Save.

http://nuget.org/packages/DotNetZip

Tomas Grosup
  • 6,396
  • 3
  • 30
  • 44
  • 1
    Then please visit [this question](http://stackoverflow.com/questions/13788140/zip-and-unzip-files-using-dotnetzip) – whoone Dec 09 '12 at 15:26
2

They have different uses. The GZipStream class is part of the framework, and has the capability of compressing a single file.

If you want to compress several files into a single archive (that can be uncompressed by someone else), you need a library that adds that capability. Such libraries can also have setting to control the balance between perforance and compression rate, to achieve better performance or better compression rate than the built in class.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • 1
    -1. Do _not_ use the GZipStream class. It is supremely buggy. (See http://stackoverflow.com/questions/11435200/why-does-my-c-sharp-gzip-produce-a-larger-file-than-fiddler-or-php/11435898#11435898 ) Use DotNetZip. – Mark Adler Dec 09 '12 at 16:05
  • @MarkAdler: Really? A downvote because you don't like the class? Are you serious? I can't see anything in the answer that you linked to that shows that the method is buggy at all. It doesn't always produce the smallest possible output, but that is a completely different thing. – Guffa Dec 09 '12 at 21:52
  • 1
    First off, yes, that is a bug. The output isn't just the smallest, it's enormous compared to the input data. A self-respecting compressor will never produce output that is any more than very slightly larger than the input. Furthermore, it never adapts the codes to the data, so it simply failing at the job called "compression". The intent of the class is to compress. It isn't. – Mark Adler Dec 09 '12 at 23:17
  • Second, the class does not properly check the CRC and lets corrupt data through. That is a huge bug. (This mentioned and linked in the answer I linked.) – Mark Adler Dec 09 '12 at 23:18
  • 2
    @MarkAdler: First, it's not a bug. Just because it doesn't meet some criteria that you have made up doesn't make it buggy. Second, I only saw you mention that, but no explanation or link to an explanation. Third, well... you don't have anything there, so there is nothing to comment... Fourth, the OP mentions GZipStream and some libraries, and I explained the most fundamental difference between them. The OP did **not** ask where to find them. So, why the downvote? – Guffa Dec 10 '12 at 00:54
  • 1
    Just because _you_ don't know anything about the deflate format doesn't mean that _I_ made something up. It's a bug. By the way, I just checked the documentation and discovered that they have fixed the bug as of .NET Framework 4.5. It says: "Starting with the .NET Framework 4.5, the DeflateStream class uses the zlib library for compression. As a result, it provides a better compression algorithm and, in most cases, a smaller compressed file than it provides in earlier versions of the .NET Framework." It doesn't say anything about the CRC problem, so I don't know if that's fixed. – Mark Adler Dec 10 '12 at 03:01