How to Download Any File in ASP.NET
Design:

Write Code in .CS File:
public void Download()
{
string filename = "Socha Na Tha ";
if (filename != "")
{
string path = Server.MapPath(filename);
System.IO.FileInfo file = new System.IO.FileInfo("D://Socha Na Tha.avi");
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-disposition", "attachment;
filename=" + filename);
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");
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Download();
}
|
Output:

When You Click Soch Na Tha Movie Button This Dialog Box Will Appear
When You Click On Save This File Any where in Computer

After This Download process Start:

Tolal:0 Click:
Show All Comments