Results 1 to 7 of 7

Thread: [RESOLVED] [2005] Multiple apps read from same file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Resolved [RESOLVED] [2005] Multiple apps read from same file

    Is it possible to have 3 different instances of the same application have a text file open for read only access?

    Which type would do it? streamReader or?

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] Multiple apps read from same file

    I would imagine you could open it for reading as many times as you needed with anything such as StreamReader.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,110

    Re: [2005] Multiple apps read from same file

    Why have them open? Open the file, read it into memory, close it. Then, even if there was a file access exception, you could wait a second and try again, as none of the programs would ever be reading the file for long.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: [2005] Multiple apps read from same file

    Well they all launch within a minute or two of each other, and if the file is left stuck open by one of the programs, I wanted the others to be able to read it.

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,110

    Re: [2005] Multiple apps read from same file

    Still, open-read-close. Do that within a Try...Catch block, and if you can't open wait for a second or so. Reading smaller files is so fast that you shouldn't have any collisions in a minute or two, or even a second or two, but if the files are HUGE, that could be an issue. I don't know whether you can have a file open for read only multiple times. It should be possible, but that comes down to OS design, I would think.
    My usual boring signature: Nothing

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] Multiple apps read from same file

    Use a SyncLock block perform operations on the file.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: [2005] Multiple apps read from same file

    I'm going to mark this thread as resolved, as it will be a few days of testing to see if the issue is still there or not. Rather not leave it up for now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width