Server Error in '/' Application.

Access to the path 'e:\home\chicsoueu\web\log\20240319.txt' is denied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 'e:\home\chicsoueu\web\log\20240319.txt' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:


Line 19: 				Directory.CreateDirectory(@sDiretorio);
Line 20: 
Line 21: 			StreamWriter oSw = File.AppendText(@sDiretorio + "\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
Line 22: 			oSw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm.ss")+ ": Method:{" + Metodo + "} - Message:" + Mensagem);
Line 23: 			oSw.Flush(); 

Source File: e:\home\chicsoueu\web\App_Code\Log.cs    Line: 21

Stack Trace:


[UnauthorizedAccessException: Access to the path 'e:\home\chicsoueu\web\log\20240319.txt' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7725711
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1162
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) +65
   System.IO.StreamWriter.CreateFile(String path, Boolean append) +62
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) +58
   System.IO.StreamWriter..ctor(String path, Boolean append) +33
   System.IO.File.AppendText(String path) +37
   Chic.Conexao.Log.InserirErro(String Metodo, String Mensagem) in e:\home\chicsoueu\web\App_Code\Log.cs:21
   Chic.Conexao.Log..ctor(String Metodo, String Mensagem) in e:\home\chicsoueu\web\App_Code\Log.cs:11
   Chic.Conexao.Areas.Listagem(String Descricao) in e:\home\chicsoueu\web\App_Code\Areas\Areas.cs:37
   Chic.Default.Area() in e:\home\chicsoueu\web\Default.aspx.cs:294
   Chic.Default.Page_Load(Object sender, EventArgs e) in e:\home\chicsoueu\web\Default.aspx.cs:208
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


Version Information: Microsoft .NET Framework Version:2.0.50727.8637; ASP.NET Version:2.0.50727.8656