2
Answers

How to download multi files in asp.net in form load?

Prabu Spark

Prabu Spark

11y
4.4k
1
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]
 

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();
 
   }
Answers (2)