Try this method .i think this will help you
private void DownloadFiles()
{
string filePath = "";
if (Convert.ToString(Request.QueryString["module"]) == "INV")
filePath = Server.MapPath("~") + Convert.ToString(ConfigurationSettings.AppSettings["Upload"]) + Convert.ToString(Request.QueryString["fileName"]);
try
{
if (File.Exists(filePath))
{
FileInfo objFileInfo = new FileInfo(filePath);
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(filePath);
Response.Clear();
Response.ContentType = GetContentType(objFileInfo.Extension);
Response.AddHeader("content-disposition", "Attachment;filename=" + objFileInfo.Name);
Response.BinaryWrite(buffer);
Response.End();
}
}
}
private string GetContentType(string strExt)
{
string type = "";
if (strExt != null)
{
switch (strExt.ToLower())
{
case ".htm":
case ".html":
type = "text/HTML";
break;
case ".txt":
type = "text/plain";
break;
case ".xml":
type = "text/xml";
break;
case ".doc":
case ".docx":
case ".rtf":
type = "Application/msword";
break;
case ".xls":
case ".xlsx":
case ".csv":
type = "Application/ms-excel";
break;
}
}
if (type == "")
return "APPLICATION/OCTET-STREAM";
return type;
}