Server Error in '/' Application.

The process cannot access the file 'E:\www\Sito\Files\ExceptionsLog\20240319_exLog.txt' because it is being used by another process.

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.IO.IOException: The process cannot access the file 'E:\www\Sito\Files\ExceptionsLog\20240319_exLog.txt' because it is being used by another process.

Source Error:


Line 31:             try
Line 32:             {
Line 33:                 sw = new StreamWriter(exFile, true, System.Text.Encoding.UTF8);
Line 34:                 sw.WriteLine(string.Format("{0}\r\n\r\nURL: {1}\r\n\r\nMessage: {2}\r\n\r\nStack Trace:\r\n{3}\r\n\r\nInner Ex: {4}\r\n\r\n-------------------\r\n\r\n", DateTime.Now, Request.Url.ToString(), ex.Message, ex.StackTrace, (null != ex.InnerException ? ex.InnerException.Message : "N/A")));
Line 35:             }

Source File: e:\www\Sito\_PageStart.cshtml    Line: 33

Stack Trace:


[IOException: The process cannot access the file 'E:\www\Sito\Files\ExceptionsLog\20240319_exLog.txt' because it is being used by another process.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +893
   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, Boolean useLongPath, Boolean checkHost) +1217
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +144
   System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) +123
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) +103
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding) +30
   ASP._Page__PageStart_cshtml.Execute() in e:\www\Sito\_PageStart.cshtml:33
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +67
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +142


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.4081.0