To download a doc file from server use the following code:
string file_path="~/files/file1.doc"; //relative path of your file on server
string filename="myfile.doc"; //your file will be downloaded with this name
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "application/msword";
response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";"); response.TransmitFile(Server.MapPath(file_path ));
string file_path="~/files/file1.doc"; //relative path of your file on server
string filename="myfile.doc"; //your file will be downloaded with this name
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "application/msword";
response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";"); response.TransmitFile(Server.MapPath(file_path ));
response.Flush();
response.End();
No comments:
Post a Comment