ASP.NET Download All Files as Zip

后端 未结 4 429
不知归路
不知归路 2020-12-14 12:31

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

4条回答
  •  失恋的感觉
    2020-12-14 13:20

    Here is code I use to do this with DotNetZip - works very well. Obviously you will need to provide the variables for outputFileName, folderName, and includeSubFolders.

    response.ContentType = "application/zip";
    response.AddHeader("content-disposition", "attachment; filename=" + outputFileName);
    using (ZipFile zipfile = new ZipFile()) {
      zipfile.AddSelectedFiles("*.*", folderName, includeSubFolders);
      zipfile.Save(response.OutputStream);
    }
    

提交回复
热议问题