Compressed files are still too big

May 14, 2012 at 8:22 PM
Edited May 14, 2012 at 8:22 PM


While reviewing this library I noticed that when using CompressionMethod.Deflate with CompressionLevel.BestCompression final file is still much bigger compared to WinZip or 7zip. By comparission:

Initial file size 17,794,454 byte

Windows Vista Send to Archive 597,558 bytes

7zip using Zip/Deflate/Ultra 524,769 bytes

DotNetZip 633,802 bytes, which is almost 21% biger than 7zip.

using (ZipFile zip = new ZipFile())
                zip.CompressionMethod = CompressionMethod.Deflate;
                zip.CompressionLevel = CompressionLevel.BestCompression;
                ZipEntry file = zip.AddEntry(Path.GetFileName(fileName), fileUpload.FileContent);
                zip.Save(Path.ChangeExtension(fileName, "zip"));

Maybe I am doing something wrong?




May 18, 2012 at 11:23 PM

Hard to say. It depends on

- the kind of file you are compressing

- the compression used by those other tools.  In some cases they don't use DEFLATE , but instead a different algorithm, which may offer better compression on some types of data.


May 18, 2012 at 11:29 PM

In case of 7-zip I di dpecify Deflat and not BZip2. If that is the case how can I achieve best compression compatible with Windows Explorer archive? Meaning so then Windows Explorer can open and unzip these files?