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
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: