I have used the following code to download files from the server which works fine in development and QA server in every browser but when it goes to production there was an error. The error is System.IO.DirectoryNotFoundException the part of the path is not correct
Code used:
protected void lnkDownload_Click(object sender, eventArgs e)
{
LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
string filePath = ((HtmlInputHidden)gvFilesDetails.Rows[gvrow.RowIndex].FindControl("hdnFileLocation")).Value.ToString();
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
Response.TransmitFile(Server.MapPath("~/" + filePath));
Response.End();
}
The issue seems to be odd and painful to debug as it only occurs in Production server. Please help me out.