ID Number: Q79676
1.00
WINDOWS
Summary:
A "Path/File access error" message is displayed when you attempt to
Open a file that already exists using the Append mode and the Write
Access clause. To prevent the error, change the Access to Read Write.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows; Microsoft QuickBasic versions 4.0, 4.0b, and
4.5 for MS-DOS; Microsoft Basic Compiler versions 6.0 and 6.0b for
MS-DOS; and Microsoft Basic Professional Development System (PDS)
versions 7.0 and 7.1 for MS-DOS.
More Information:
Steps to Reproduce Problem
--------------------------
To cause the error in the Visual Basic environment (VB.EXE), open the
Immediate window (debug window) and type the Open statement in step 4:
1. Run any program.
2. Press CTRL+BREAK, or from the Run menu, choose Break.
3. From the Window menu, choose Immediate window.
4. Write the following statement in the Immediate window
Open "filename" for Append Access Write as #1
where "filename" is a valid filename. If the file does not exist,
the command will complete successfully and you'll have to type
Close #1
on the next line. If you execute the same Open command again, or if
the file existed when you executed the first Open, the alert
"Path/File access error" will be displayed. If you change Write to
Read Write, the command will be successful.
The reason for this behavior is that when a file is opened for Append,
Basic searches for the end of the file and sets the file pointer
there. If the Access for that file is restricted to Write, Basic
cannot Read the file to complete its search.
The Open statement is successful if the file did not exist because the
Append mode automatically creates it and puts the end-of-file marker
at the beginning of the file. Basic then does not have to search the
file to find the marker, and the write-only access on the file causes
no conflict.
Additional reference words: 1.00 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10