Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi sir,
Tell me the steps to download multi files using asp.net c#. I stored the filenames in string array and put in for loop, but for loop is going one time only. i attached the code for your reference. Kindly give me the solution for this problem.


[Note: Because of Response.End() it will not go to next value increment in for loop]


C#
protected void Page_Load(object sender, EventArgs e)
   {
       string[] values = { "setup1.apk", "setup1.apk" };

       for (int i = 0; i < values.Length; i++)
       {
           downloadfiles(values[i]);
       }

   }

   private void downloadfiles(string filename)
   {
       Response.Cache.SetCacheability(HttpCacheability.NoCache);
       Response.ClearContent();
       Response.Clear();
       Response.ContentType = "application/msi";
       Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
       Response.TransmitFile(Server.MapPath("~/jad/") + filename);
     
       Response.End();

   }
Posted
Updated 23-Sep-19 5:32am

Hi,

have you debugged your code? if you debug your code you will find
Response.End();
in
downloadfiles
() function. comment it and it will loop thorough second time.

thanks
 
Share this answer
 
Hi sir,
If i remove Response.End() in downloadfiles functions, no file downloaded for me.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900