Hi
I have a filename link & i want when user clicks on it user should be able to open or able to download it . File is stored in a folder as a GUID.
Thanx
File Open / Download
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Krishna GaradRank #191 · 12.8K reputationPosted Jan 30, 2012, 6:26 PM EST
private void DownloadFile(string fname, bool forceDownload)
{
string path = MapPath(fname);
string name = Path.GetFileName(path);
string ext = Path.GetExtension(path);
string type = ReturnExtension(ext);//provide the exetention of file
if (forceDownload)
{
Response.AppendHeader("content-disposition",
"attachment; filename=" + name);
}
if (type != "")
Response.ContentType = type;
Response.WriteFile(path);
Response.End();
}