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?
Printable View
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?
I would imagine you could open it for reading as many times as you needed with anything such as StreamReader.
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.
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.
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.
Use a SyncLock block perform operations on the 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.