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
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist