Sunday, July 20, 2008

Download Method

public void downloadmethod(string filename)
{
if (filename != "")
{

string path = Server.MapPath(@"Invoice\" + 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();
}



}

}