0

in a project asp.net, I generate invoices with active reports and I save them in pdf format. there I want to create a zip file dynamically and add the pdf invoices then downloading this file zip in client side. help me please.

Jawadovic3814
  • 407
  • 1
  • 4
  • 8
  • look [here](https://stackoverflow.com/questions/681827/how-to-create-and-fill-a-zip-file-using-asp-net) to create zip files in asp.net & [here](https://stackoverflow.com/questions/8897458/asp-net-download-file-to-client-browser) to download files. – yekanchi May 21 '18 at 03:52
  • I tried the code but I have an error on the zipFilename variable on the line: using (Package zip = System.IO.Packaging.Package.Open(zipFilename, FileMode.OpenOrCreate)) "Access to the path 'C:\Program Files (x86)\IIS Express\Output.zip' is denied." – Jawadovic3814 May 21 '18 at 19:31
  • manually give a path to zip file – yekanchi May 21 '18 at 23:48

1 Answers1

0
        string zipFileName = "a.zip"; 
        using (var zip = new ZipFile())
        {
            System.IO.File.Delete(fileDir + "/" + zipFileName);
            zip.AddDirectory(fileDir + "/");
            zip.CompressionLevel = CompressionLevel.Level5;
            zip.CompressionMethod = CompressionMethod.BZip2;
            zip.Save(fileDir + "/" + zipFileName);
        }
zaman
  • 145
  • 7