Skip to content

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

SURAJ KSHIRSAGAR

SURAJ KSHIRSAGAR

Asked Jan 18, 2017, 8:30 PM EST1 answer
Share
LinkedInX
C#
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);
                    }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • SURAJ KSHIRSAGAR
    0
    from above code file not zip but with same file name other empty zip file created to destimnation
    0