Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Possibility of Exception? (With Code)

Possibility of Exception? (With Code)

Scheduled Pinned Locked Moved ASP.NET
csharpwpfsysadminquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mitch F
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • M Mitch F

      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

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • P pmarfleet

        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

        M Offline
        M Offline
        Mitch F
        wrote on last edited by
        #3

        Great, thanks for the reply. I wasn't sure how Windows would handle two separate read requests at the same time. Thanks, Mitch

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups