protected void DownloadFile(string Path, string FileName)
{
try
{
string strURL = Path;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename="+FileName);
byte[] data = req.DownloadData(Server.MapPath(strURL));
response.BinaryWrite(data);
response.End();
}
catch (Exception ex)
{
}
}

Programming is fun and interesting. As you all know, sometime we programmers stucks in the middle way of coding without getting a solution. Blogs like this will help us to find a path to solve our problems. The contents of this blog are the solutions that I found by myself and from other sources. Sharing such solutions is also interesting. Thank you!
Showing posts with label Asp.net C# code for download file. Show all posts
Showing posts with label Asp.net C# code for download file. Show all posts
Sunday, May 24, 2015
Asp.net C# code for download file
Subscribe to:
Posts (Atom)