Hi All,
I need to add some files to the folder and zip that folder and attach the same to the mail. For this I am using following code but could able to zip the required folder.
ZipFile zip = new ZipFile();
for(int i=0;i<attachments.Length-1 ; i++)
{
System.IO.FileInfo f = new System.IO.FileInfo(attachments);
zip.AddFile(attachments);
}
zipfile = "myfolderpath is given here";
zip.Save(zipfile);
The result what I am getting is, I am able to add files to the specified path but the folder is not getting zipped.
Regards,
Praveen
Zipping Functionality
Re: Zipping Functionality
This is my method for zipping, its similar and works fine...
Code: Select all
public static void CreateZip(string zipName, params string[] filePathsToZip){
using (ZipFile zip = new ZipFile())
{
foreach (string file in filePathsToZip) {
if(File.Exists(file)){
zip.AddFile(file);
}
}
zip.Save(zipName);
}
}