main page >programming tips (VB5/6) > Check if a folder exists diese Seite auf deutsch | |
Here is a function that checks whether a particular folder exists, without any dependency to a library like the
FSO. Whenever the folder does not exist, or access to a drive that
isn't ready is attempted, the error is trapped and the return value is set accordingly.
Oftenly people use "If Dir$(Filename, vbDirectory) <> "" Then ..." for this check, but this
method is not recommended since Dir$ is not re-entrant; that means that a call to Dir$
within an outer Dir$-Loop would terminate the outer loop.
Update: As mentioned in the article "Check if a file exists", GetAttr() is a little bit outdated. Since GetAttr() is only a wrapper for the API function GetFileAttributes(), it's better to call GetFileAttributes() directly:
|
|
main page > programming tips (VB5/6) > this page | |
© 2001-2021 Wolfgang Enzinger |