This is the method i created which takes a zip file and unzips it and puts all the pdfs that were in the zip in the downloads directory.
My last step will now be to create a method that opens each PDF.
[HttpGet]
public void UnZipDownload()
{
if(TempData["ZipName"] != null)
{
string zipName = TempData["ZipName"] as string;
string downloadPath = new KnownFolder(KnownFolderType.Downloads).Path;
string filePath = new KnownFolder(KnownFolderType.Downloads).Path;
downloadPath = Path.GetFullPath(downloadPath);
if (!downloadPath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
downloadPath += Path.DirectorySeparatorChar;
using (ZipArchive archive = ZipFile.OpenRead(filePath + "\\" + zipName))
{
foreach(ZipArchiveEntry entry in archive.Entries)
{
if(entry.FullName.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase))
{
string destinationPath = Path.GetFullPath(Path.Combine(filePath, entry.FullName));
entry.ExtractToFile(destinationPath);
}
}
}
}
}