Friday, October 7, 2011

Using DotNetZip to Compress all the Files in a Folder in C#

The inbuilt Compression class GzipStream class(System.IO.Compression) for C# does not provide the ability to compress all the files within a folder.You can do this by just few lines of code and just forgetting the techinical aspects behind it by using DotNetZip(Ioniczip).DotNetZip is a free class library that can be used for creating and editing zip files.

The project is Hosted at CodePlex check out
To use DotNetZip Library in your C# Project follow these steps
  • Download the latest release from
  • Add a Reference to DotNetZip from your project by going to Project> Add Reference .Browse for Ionic.Zip.dll in the release that you have downloaded.
  • Then add the reference in your project by adding the statement 'using Ionic.Zip'
  • Then use the code given below to create a zip file from a folder
 using (ZipFile zip = new ZipFile())  


Post a Comment


The Source Codes Published in this Blog can be used freely for Educational purposes but should not be reproduced on any other Blog or Website without the consent of the author.