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