I have an MVC3 C#.Net web app. I am needing to zip a subset of files in a folder and save to the user’s Harddrive. I already am downloading individual files, but need to have “Download Multiple Files” functionality. Below is the code for individual files.
fileName = fileName.Contains("Artifact") ?
fileName.Substring(fileName.LastIndexOf("Artifact:") + 11).Trim() :
fileName.Substring(fileName.LastIndexOf("Working Document:") + 19).Trim();
var fs = System.IO.File.OpenRead(GetDirectoryPath(boeId, proposalId, aType) + "\\" + fileName);
return File(fs, "application/zip", fileName);
I ended up using System.IO.Packaging. Attached is the url I used for example code
System.IO.Packaging example.