SURAJ KSHIRSAGAR

SURAJ KSHIRSAGAR

  • NA
  • 44
  • 1.3k

Zip a file from folder using ICON ZIP but empty zip created

Jan 19 2017 1:30 AM
using (Ionic.Zip.ZipFile Zip = new Ionic.Zip.ZipFile())
{
string filename = AttchmentFileName.Substring(0, AttchmentFileName.Length - 4);
string filenameE = AttchmentFileName.Substring(12);
filename = filename.Substring(12);
string zipfile = filename + ".Zip"; 
var zip = new ZipFile();
zip.Password = "123";
zip.Encryption = EncryptionAlgorithm.WinZipAes256; 
string filenameWitoutextension = Path.GetFileNameWithoutExtension(@"C:\Template"); 
string destdir = @"C:\Template\" + filename + ".zip";
zip.AddEntry(filenameE, "");
zip.AddSelectedFiles(filenameE); 
zip.Save(destdir); 
System.Web.Mail.MailAttachment attachment = new MailAttachment(filename);
message.Attachments.Add(attachment);
}

Answers (1)