devxlogo

Checking for Existence of a File

Checking for Existence of a File

Question:
How do you check to see if the name of a file you want to RENAME a file to already exists?

Answer:
Here is a great example of how to determine the existence of any file:

   Sub Command1_Click()      Dim TheFile as String      Dim Results as String      TheFile = "C:README.TXT"      Results = Dir$(TheFile)      If Results  = "" Then         MsgBox "File Doesn't Exist!"      Else         MsgBox "File does Exist!"      End If   End Sub
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