Subhash Sharma

Subhash Sharma
Subhash Sharma

This is Subhash Sharma(Software Engineer) Blog

Welcome to this blog and find every solution.............

Search This Blog

Software Engineer(Subhash Sharma)

Software Engineer(Subhash Sharma)
Software Engineer

Tuesday, December 28, 2010

Zip and Unzip the File(Through Ionic .Dll)

Download ionic.Dll from(http://dotnetzip.codeplex.com/releases/view/27890)
and Add the Dll through Add reference and Add the NameSpaces (using Ionic.Zip;)

ZipFile zip = new ZipFile();

// add this map file into the "images" directory in the zip archive
DirectoryInfo f = new DirectoryInfo("c:\\images");
FileInfo[] a = f.GetFiles();
for (int i = 0; i < a.Length; i++)
{
zip.AddFile("c:\\images\\" + a[i].Name, "images");
}
zip.Save("c:\\MyZipFile.zip");
String TargetDirectory = "c:\\MyZipFile.zip";
using (Ionic.Zip.ZipFile zip1 = Ionic.Zip.ZipFile.Read(TargetDirectory))
{
zip1.ExtractAll("c:\\UnZip",
Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite);
}