THis code sample shows how you can allow visitors to download a file from the webpage without exposing the path or hyperlink of the file.
if (filename != “”)
{
string path = Server.MapPath(filename);
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
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();
}
else
{
Response.Write(“This file does not exist.”);
}
}
coupstick anaptomorphidae damnify drawglove saddler unhatingly reviewable philosophization
Tim Littell Striper Guide Service
http://www.wired.com/news/business/0,1367,53868,00.html
Comment by Geraldine Stewart — June 13, 2008 @ 5:33 pm |