Unzip files programmatically in C# – #ZipLib


So this was the first time I had to do this and I started to google… I was looking for a plain and simple way of unzipping a previously zipped file.

The results included:

  • System.IO.Compression that has been added in .NET 2.0 – used to compress and decompress streams. This didn’t exactly look like what I wanted and a lot of work.
  • WinRAR add-on that contained an UnRAR.dll for Windows. Michael A. McCloskey created a wrapper class for this which makes it much easier to use, but unfortunately I ran into troubles with .NET 2.0.
  • WinZip has a command line add-on which allows you to use batch files to extract the files from the zip, but a license for WinZip 10 Pro is needed.
  • #ziplib/SharpZipLib which was created by the guys from SharpDevelop. Entirely C#. This definitely looked like what I was looking for….

So I downloaded #ziplib and started looking at examples and jumped in and wrote some code… Created some GZipOutputStreams and FileStreams and tested and it didn’t work and I played around a bit more… During my searches I came across a post where someone mentioned FastZip, which is part of #ziplib and can be used for basic functions….

After a days searching and playing around and lines and lines of unnecessary code all I needed was the following:


using ICSharpCode.SharpZipLib.Zip;
FastZip fz =
new FastZip();       
fz.ExtractZip(zipFile, targetDirectory,"");


Very Cool. Is n’t it?




2 thoughts on “Unzip files programmatically in C# – #ZipLib

  1. I googled for a simular need and got this. Thank you for taking the time to share your findings. This saved me hours. Other developers learn from this example.  🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s