User Id :    Password :      New Member   Forgot Password  
File Downloading Code in C#
Description Generally we provide the facility to download certain file on some event like button click. So here I am providing simple code to do this.   No. of Views     1347
  Rating     5
Author Sumit Gupta   Posted On     15 Apr 2011
Tags ASP.NET,C#    

Sample Code   Download Code

using System.IO;

 FileInfo finfo = new FileInfo(Server.MapPath("~/YourFolderName/YourFileName"));
        if (finfo.Exists)
            Response.AddHeader("Content-Disposition", "attachment; filename=" + finfo.Name);
            Response.AddHeader("Content-Length", finfo.Length.ToString());
            Response.ContentType = "application//octet-stream";


About Author

About Author I am Sumit Gupta working in 3 Pillar Global Pvt. Ltd as Module Lead. I have 7+ year of experience in .Net technologies. I love to explore new technologies and write technical article. Sumit Gupta
No Photo
Country India
Company 3 Pillar Global Pvt. Ltd.
Home Page

Rate this article

Rating options from poor, fair, good, very good to excelent.  


Write your comment here.
Verification Code