Friday, December 3, 2010

Zipping a folder which contains multiple files using Ionic.Zip.dll library


              String ReadmeText = string.Format("This file was created automatically by..... application on," + DateTime.Now.ToString("yyyy-MMM-dd--HH:mm:ss"), DownloadfileName, Environment.NewLine);
                StreamWriter sw = File.CreateText(Server.MapPath("~//zipfolder//Readme.txt"));
                sw.WriteLine(ReadmeText);
                sw.Close();
                string path = Server.MapPath("~//zipfolder//MyZipFile");
                using (ZipFile zip = new ZipFile())
                 {
                     zip.AddFile(Server.MapPath("zipfolder//Readme.txt"),"");
                     zip.AddFile(Server.MapPath("xmlfolder//ss.xml"),"");
                     zip.Save(Server.MapPath("~//zipfolder//MyZipFile.zip"));
                  }

No comments:

Post a Comment