B
Bill
In the DownLoad method below, the path I am passing to the
streamwriter object is triggering the following exception but I dont
know why.
Access to the path 'E:\clnts\www.myapp.com\downloads.log' is denied.
This happens only on the host web server. No error on a local machine.
The streamwriter successfully writes to the downloads.log file, but if
I remove the try/catch block then I get an unhandled excpeption and
the downloads.log file is not written to. So my page works, and I can
simply remove the redirect to the errorpage and forget about it, but I
sure would like to know what is causing the error. Seems to be some
sort of permission violation, but why does it go ahead and write to
the file if that is the case?
protected void DownLoad(object sender, EventArgs e)
{
Response.Redirect("~/Downloads/xmlmaxbeta.zip", false);
//executes before dialog is shown
try
{
using (System.IO.StreamWriter sw = new
System.IO.StreamWriter(Server.MapPath("~/") + "downloads.log", true))
{
//write comma delimited string so file may be loaded
into excel and sorted
sw.WriteLine(DateTime.Today.ToShortDateString() + ","
+ Convert.ToString(Session["PwdHash"]));
sw.Close();
}
}
catch (System.IO.IOException ioex)
{
Session["ErrorMessage"] = ioex.Message + " IO exception";
Response.Redirect("~/ErrorPage.aspx");
}
catch (Exception ex)
{
Session["ErrorMessage"] = ex.Message + " general
exception";
Response.Redirect("~/ErrorPage.aspx");
}
}
streamwriter object is triggering the following exception but I dont
know why.
Access to the path 'E:\clnts\www.myapp.com\downloads.log' is denied.
This happens only on the host web server. No error on a local machine.
The streamwriter successfully writes to the downloads.log file, but if
I remove the try/catch block then I get an unhandled excpeption and
the downloads.log file is not written to. So my page works, and I can
simply remove the redirect to the errorpage and forget about it, but I
sure would like to know what is causing the error. Seems to be some
sort of permission violation, but why does it go ahead and write to
the file if that is the case?
protected void DownLoad(object sender, EventArgs e)
{
Response.Redirect("~/Downloads/xmlmaxbeta.zip", false);
//executes before dialog is shown
try
{
using (System.IO.StreamWriter sw = new
System.IO.StreamWriter(Server.MapPath("~/") + "downloads.log", true))
{
//write comma delimited string so file may be loaded
into excel and sorted
sw.WriteLine(DateTime.Today.ToShortDateString() + ","
+ Convert.ToString(Session["PwdHash"]));
sw.Close();
}
}
catch (System.IO.IOException ioex)
{
Session["ErrorMessage"] = ioex.Message + " IO exception";
Response.Redirect("~/ErrorPage.aspx");
}
catch (Exception ex)
{
Session["ErrorMessage"] = ex.Message + " general
exception";
Response.Redirect("~/ErrorPage.aspx");
}
}