R4R
Right Place For Right Person TM
R4R ASP.Net with C# ASP.NET Tutorials How to Download Any File in ASP.NET
previous

Home

Next

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:

previous

Home

Next


Tolal:0 Click:
Show All Comments

Post Your Comments

Your Name:

Your Email ID :
Comments :
URL
  =* Enter SUM

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R