I have a folder on my web server that has hundreds of mp3 files in it. I would like to provide the option for a user to download a zipped archive of every mp3 in the directo
I can't believe how easy this was. After reading this, here is the code that I used:
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.BufferOutput = false;
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment; filename=pauls_chapel_audio.zip");
using (ZipFile zip = new ZipFile())
{
zip.CompressionLevel = CompressionLevel.None;
zip.AddSelectedFiles("*.mp3", Server.MapPath("~/content/audio/"), "", false);
zip.Save(Response.OutputStream);
}
Response.Close();
}