my requirement : i want to download a exe file from my website using asp and c#
i am trying this code:
protected void btn_download_Click(object sender, EventArgs e) { string filename = "SherAcc.exe"; if (filename != "") { string path = Server.MapPath(filename); System.IO.FileInfo file = new System.IO.FileInfo(path); if (file.Exists) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; SheraAcc=" + file.Name); 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."); } } }The output : downloading the page
note : exe file place in same location of the project no additional folder used
Raja TPosted Jul 10, 2015, 8:09 AM
Muhammed ShafeequePosted Jul 11, 2015, 3:19 AM