So I finally got this to work and download my pdf files into a zip file. See below:
List<string> manypaths = (List<string>)TempData["temp"];
var startpath = manypaths;
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");
}
So the manypaths list variable is holding onto a few paths to the pdf file which are like \\\\ost-stji01\pdfstorage\deposit\02_29_2019.pdf
So when the user downloads these files they have to click through multiple folder structure i.e ost0ji01 > pdfstorage > desposit >
then they get to their file.
My question is how can i download just the files and not the entire folder structure. SO when they open the zip file its all of the files and they don't have to go through 3 or 4 folder directories.
If you want to flatten the paths in your ZIP file, use this.
zip.AddFiles(manypaths, @"\");
The second parameter of AddFiles
allows you to specify the path of your files in the archive and \
is the root in your archive. Therefore, all files will be located directly in your archive without subfolders.