Download Word Documents from Server Using ASP.Net and C#
Again, this is for beginners to have a method of downloading and reading word documents from server.
In the last article that I wrote, we have seen how to read a word document present in the same system using a windows application.
Here in this article, we are going to see how to read a word file available in the server or even download it to local system.
The implementation is very simple.
Using Response.WriteFile, on giving the filename as argument when the user clicks the appropriate link in the webpage.
if (filename != "")
string path = Server.MapPath(filename);
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.ContentType = "application/octet-stream";
Response.Write("This file does not exist.");