Thea Burger's Blog

Wouldn't you like to know...

News

Photo's!!!

About me

I'm Reading: General Blogs

I'm Reading: Technical Blogs

January 2006 - Posts

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 :P
  • 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,"");


Can you freaking believe it!!?

Posted: Jan 17 2006, 07:24 PM by Thea Burger | with 22 comment(s)
Filed under: