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.
|