PRB: Search Using OpenFile API Instead of Dir/Dir$ Function (168519)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual Basic Standard Edition for Windows 4.0
- Microsoft Visual Basic Professional Edition for Windows 4.0
This article was previously published under Q168519 SYMPTOMS
The Dir/Dir$ function in Microsoft Visual Basic may be used to test for
a file's existence. It returns the name (or names) of the files that fit
the search criteria. However, when using a UNC (Universal Naming
Conventions) path to search for files that exist on a network directory,
the Dir$ function may not return valid information. This behavior is most
common when searching network paths. It can also
occur when searching for files that have unusual names (such as files that
have no extension).
RESOLUTION
To work around this behavior, the OpenFile API call may be used to test for
the existence of a file. Passing the parameter OF_EXIST to the OpenFile
function causes OpenFile to search for an existing file. It does not write
to or open the file when this parameter is passing by itself.
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base:
112674
: How to Determine If a File Exists by Using DIR$
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | kbAPI kbprb KB168519 |
---|
|