Prabu Spark

Prabu Spark

  • NA
  • 124
  • 199.3k

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

Aug 5 2013 3:01 AM

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 (3)