Server Error in '/' Application.

The process cannot access the file 'C:\inetpub\Kidney2021\ipx\ipLOG__2024_03_28.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 'C:\inetpub\Kidney2021\ipx\ipLOG__2024_03_28.txt' because it is being used by another process.

Source Error:


Line 34:                 string dtX = DateTime.Now.ToString("yyyy_MM_dd");
Line 35:                 string path = System.Web.HttpContext.Current.Server.MapPath("/ipx/ipLOG__" + dtX + ".txt");
Line 36:                 using (var tw = new StreamWriter(path, true))
Line 37:                 {
Line 38:                     System.TimeZoneInfo tzi = System.TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");

Source File: c:\inetpub\Kidney2021\MasterRoot.master.cs    Line: 36

Stack Trace:


[IOException: The process cannot access the file 'C:\inetpub\Kidney2021\ipx\ipLOG__2024_03_28.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) +55
   MyWeb.MasterRoot.Page_Load(Object sender, EventArgs e) in c:\inetpub\Kidney2021\MasterRoot.master.cs:36
   System.Web.UI.Control.OnLoad(EventArgs e) +106
   System.Web.UI.Control.LoadRecursive() +68
   System.Web.UI.Control.LoadRecursive() +162
   System.Web.UI.Control.LoadRecursive() +162
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785


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