Click here to Skip to main content
15,893,337 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Friends,
I have a excel file in server. And i have a button in a web form. When user clicks that button it will download that excel file to client machine.

I need that code urgently.

Thanks
Sunil
Posted

 
Share this answer
 
Plz go through below code ....

C#
public void downloadXlFile(string url, string filePath)
       {
           if (File.Exists(filePath))
           {
               File.Delete(filePath);
           }
           //Downloading file form Http Url
           WebClient myWebClient = new WebClient();
           myWebClient.DownloadFile(url, filePath);
           //CompleteDownloading file form Http Url
       }
 
Share this answer
 
Comments
Rock (Multithreaded) 17-Aug-12 7:01am    
Man, he is talking about WebForms not about WinForms.
I am using this below code

C#
Response.ContentType = "image/jpeg";
        Response.AppendHeader("Content-Disposition", "attachment; filename=Image.xml");
        Response.TransmitFile(Server.MapPath("XML/Image.xml"));
        Response.End();


It is working fine but when i keeping it within Update Panel not working. Any suggestion.
 
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