Possibility of Exception? (With Code)
-
Hi, Currently, in my ASP .Net project, I read text from a text file using a streamreader. The code I use is below:
<% Dim sR As New IO.StreamReader(IO.Path.Combine(Server.MapPath("~"), "templates/menu.txt")) Do Dim line As String = sR.ReadLine Response.Write(line) Loop Until (sR.EndOfStream = True) sR.Close() %>
Will an exception be thrown if two separate people access the same page at the same time, thereby causing two streamreaders to try and access the same file? Thanks in advance, Mitch -- modified at 14:15 Friday 9th November, 2007 -
Hi, Currently, in my ASP .Net project, I read text from a text file using a streamreader. The code I use is below:
<% Dim sR As New IO.StreamReader(IO.Path.Combine(Server.MapPath("~"), "templates/menu.txt")) Do Dim line As String = sR.ReadLine Response.Write(line) Loop Until (sR.EndOfStream = True) sR.Close() %>
Will an exception be thrown if two separate people access the same page at the same time, thereby causing two streamreaders to try and access the same file? Thanks in advance, Mitch -- modified at 14:15 Friday 9th November, 2007I believe that this is OK. A file can be accessed by more than 1 process, as long as another process has not locked or prohibited read access to the file. If you were writing to a file, you would want to lock all or part of it to ensure that your changes were not overwritten by another process.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
I believe that this is OK. A file can be accessed by more than 1 process, as long as another process has not locked or prohibited read access to the file. If you were writing to a file, you would want to lock all or part of it to ensure that your changes were not overwritten by another process.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush