Scroll To Top
Reader Level:
Web Development

Download Word Documents from Server Using ASP.Net and C#

By Krishnan LN on Feb 28, 2006
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.


string filename="Connectivity.doc";

if (filename != "")


          string path = Server.MapPath(filename);

          System.IO.FileInfo file = new System.IO.FileInfo(path);

          if (file.Exists)



                   Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);

                   Response.AddHeader("Content-Length", file.Length.ToString());

                   Response.ContentType = "application/octet-stream";






                   Response.Write("This file does not exist.");