Let's say that I have a website where I'd like users to be able to download a certain group of files. There will be checkboxes and listboxes of options for users to choose from, so that they can select what parts they want to include and what they don't want to download. Then, they click the Download button and their browser downloads a zip file containing only the things they selected.
I want to accomplish such a hypothetical situation with ASP.NET and C#. Of course, I could make zip files of all the permutations, but that would take a LOT of time. Is it somehow possible, if I have the file paths of files stored on my server, to take some of those files, zip them up (in memory or on disk and then delete it), and send the zip file to the client thru the Response?
UPDATE: I just found the following question and code sample thru the Related box:
private void sendToClient(Dictionary<string, string> reportDic)
{
Response.Clear();
Response.BufferOutput = false;
String ReadmeText = "some text";
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=" + "filename.zip");
using (ZipFile zip = new ZipFile())
{
zip.AddEntry("Readme.txt", ReadmeText);
zip.Save(Response.OutputStream);
}
Response.Close();
}
It uses DotNetZip to zip up the file.
Do you think this is what I'm looking for? I'm going to go read the docs of DotNetZip.