Server Error in '/' Application.

The process cannot access the file 'C:\Inetpub\vhosts\dmcs.com.vn\httpdocs\visitor.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\vhosts\dmcs.com.vn\httpdocs\visitor.txt' because it is being used by another process.

Source Error:


Line 61:     {
Line 62:         double _visitor = 0;
Line 63:         TextReader tr = new StreamReader(Server.MapPath("visitor.txt"));
Line 64:         _visitor = Convert.ToDouble(tr.ReadLine());
Line 65:         tr.Close();

Source File: c:\inetpub\vhosts\dmcs.com.vn\httpdocs\MasterMainPage.master.cs    Line: 63

Stack Trace:


[IOException: The process cannot access the file 'C:\Inetpub\vhosts\dmcs.com.vn\httpdocs\visitor.txt' because it is being used by another process.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7724048
   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.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) +87
   System.IO.StreamReader..ctor(String path) +30
   MasterMainPage.VisitorCounter() in c:\inetpub\vhosts\dmcs.com.vn\httpdocs\MasterMainPage.master.cs:63
   MasterMainPage.Page_Load(Object sender, EventArgs e) in c:\inetpub\vhosts\dmcs.com.vn\httpdocs\MasterMainPage.master.cs:40
   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.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


Version Information: Microsoft .NET Framework Version:2.0.50727.3662; ASP.NET Version:2.0.50727.3668