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.");