0

I am trying to download a zip of pdf files without having to go through the full directory path

So when I am downloading the files the user will have to click through the entire path to get to the pdf. I want just the files to download without the entire path.

So I did this:

public ActionResult DownloadStatements(string[] years, string[] months, string[] radio, string[] emails, string acctNum)
    {
        
        List<string> manypaths = (List<string>)TempData["temp"];
        
        using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
        {

            zip.AddFiles(manypaths , @"\");

            MemoryStream output = new MemoryStream();
            
            zip.Save(output);
            return File(output.ToArray(), "application/zip");
           
        }
    }

In the line zip.AddFiles(manypaths, @"\") I added the @"\" and that seemed to do the trick. But now at that line of code I am getting an error:

System.ArgumentException: 'An item with the same key has already been added.

None of the files are duplicates as I have checked that. I just don't understand what is going on?

I was thinking about maybe if I added a timestamp to it it might help but can't figure out the proper way to do this in dotnetzip library.

theduck
  • 2,589
  • 13
  • 17
  • 23

0 Answers0