Nov 26, 2011

How to zip a file in C# .NET?

To zip a file in .net you can use Ionic.Zip dll

Example :-

using Ionic.Zip;
FileInfo fi = New FileInfo(yourFilePath);
Using ZipFile zip = New ZipFile()
{
      zip.AddFile(yourFilePath, "");
      zip.Save(yourFilePath.Replace(fi.Extension, ".zip"));
}

Click Here to download Ionic.Zip

2 comments:

Krishna Sanghi said...

How to unzip a file ?

Hemant Sarraf said...

http://hemantsarraf.blogspot.com/2011/11/how-unzip-zip-file.html