I am trying to get a file from my Server.Mappath("/Test.txt"); file. I am getting an error
code
proteced void lnkDownload_Click(object sender,EventArgs e)
{
string strFileName = lnkDownload.Text;
string path = Server.MapPath("~/Attachments//" + strFileName);
try
{
if (File.Exists(path))
{
byte[] bts = System.IO.File.ReadAllBytes(path);
MemoryStream ms = new MemoryStream(bts);
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + strFileName + "\"");
Response.TransmitFile(path);
Response.End();
}
}
catch(Exception ex)
{
throw ex;
}
}
Error : When code execution reaches to Response.End() there it is giving some unknown error
exception details showing like above attached image. But final exception comming like
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End()