devxlogo

File Exists?

File Exists?

One way to test whether a specific file exists is to open thefile for input and check VB’s error flag. An error will occurif the file does not exist.

Use VB’s ‘Dir$’ function to accomplish the same task. Call ‘Dir$’with the complete filespec. ‘Dir$’ will return the exact filename if that file exists or a null string if it does not. Forexample:

          If Dir$("C:WINDOWSWIN.INI") _                 "" Then                'file Win.ini exists!         Else                'file Win.ini does not exist!         End If

devx-admin

Share the Post: