there are several aspects of file i/o that you need to work with.
The first is file permissions.
open mode specifies whether this function opens the file for both reading
and writing data, for reading only, or for writing only. open mode defaults
to 0 if you do not wire it.
0 May both read and write to file.
1 May only read from file.
2 May only write to file. Does not truncate (remove all data from) the file.
Under any non-Macintosh platform, this mode acts like mode 0.
3 May only write to file. Truncates the file.
deny mode specifies the degree to which other users can operate on the file
simultaneously. deny mode defaults to 2 if you do not wire it.
0 Deny both read and write to the file by other users.
1 Permit read but deny write to the file by other users.
2 Permit both read and write to the file by other users.
Since the default permission is to permit both read and write, that would
explain why your test case works as it does.
Arbitrating the usage of the file can be accomplished a couple of ways.
If one process opens the file for exclusive read/write, other file opens
will fail and they will have to implement a retry mechanism.
If one process opens the file for mutual use, both processes will have to
use file locks with retries to access various parts of the file.
You will have to code the retry mechanism yourself.
Stu
Stephen Gray wrote in message
news:3A71A3EF.36D39A04@swri.org...
> I'm trying a test VI to see how Open File VI works. I have one VI that
> opens a file "test.txt" and keeps it open (constantly reading from the
> file). I have another VI running simultaneously that opens the file and
> writes to the file "test.txt". Why is this allowed? I thought it would
> let the file only be openned one at a time.
>
> What if two VI's were trying to write to the same file at the exact same
> time? Do I need to implement some sort of check for this? I have
> multiple VI's running that 'could' write to the same file at the same
> time.
>
> thanks,
> stephen