I'm pretty new at this, so bear with me. Here's my code. It only downloads one file even though multiple are selected.
foreach(String fileName in fileNameList)
{
FileInfo updateFile = new FileInfo("C:/inetpub/wwwroot/w4/DanyaWebReports/Data/" + fileName);
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition", "attachment;filename=\"" + Path.GetFileName(updateFile.FullName) + "\"");
Response.AddHeader("content-length", updateFile.Length.ToString());
Response.TransmitFile(updateFile.FullName);
Response.Flush();
}
that is not the way to go, you can either zip all selected files server side and download only the zip file or you can try to use client side code to open multiple download windows, but in that case I think some browsers could potentially block the popups with their popup blockers.
something like, you create a page called download.aspx ( or even just an http handler ) then you call it multiple times via JavaScript:
window.open("download.aspx?id=id of file1");
window.open("download.aspx?id=id of file2");
check here for some ideas you can further elaborate: ASP.NET Download Multiple files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With