How to download file in

Hi Friends,

Today I am going to describe file download functionality in

we can download file using different methods in

Today I am going to describe Response.TransmitFile method of

Lets see how can we do it

public void Downloadfile(string fileName, string filePath )
    FileInfo file = new FileInfo(filePath + "\\" + fileName);
    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
    Response.AddHeader("Content-Length", file.Length.ToString());
    Response.ContentType = "application/octet-stream";
    Response.TransmitFile(filePath + "\\" + fileName);

You can download file easily by using above function.
1. You need to pass fileName and filePath parameters
2. Here, I have used general content type “application/octet-stream”. Change it as per your requirement
3. Add reference for System.IO

Hope this will help you !!!!