in c#.net
string path = Server.MapPath(“~”).ToString() + @”[Filename]“;
if (File.Exists(path))
{
Response.AppendHeader(“content-disposition”,”attachment; filename=[FileName]“);
Response.ContentType = “application/x-msdownload”;
Response.TransmitFile(path);
}
else
{
string nofile = “<script language=javascript>alert(‘File Not available’);</script>”;
Page.RegisterStartupScript(“nofile”, nofile);
}