View Single Post
 
Old June 15th, 2007, 02:45 AM
mike_remember mike_remember is offline
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

I am writing this code as an example which assumes that there is a folder named Upload with a notepad file testdata.txt within your webapplication.

string path = Server.MapPath("~/Upload/testdata.txt");
            FileInfo file = new FileInfo(path);

            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
            Response.AddHeader("Content-Length", file.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(file.FullName);
            Response.End() ;

Regards
Mike

Don't expect too much, too soon.