how can I check if a file exists?

120,940

Start with this:

Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(path)) Then
   msg = path & " exists."
Else
   msg = path & " doesn't exist."
End If

Taken from the documentation.

Share:
120,940
Cocoa Dev
Author by

Cocoa Dev

Updated on February 15, 2020

Comments

  • Cocoa Dev
    Cocoa Dev over 4 years

    I want to check to see if a file exists and if it does, I want to open it and read the 1st line,

    If the file doesn't exist or if the file has no contents then I want to fail silently without letting anyone know that an error occurred.

  • Seeta Somagani
    Seeta Somagani about 11 years
    This answer does not answer the question. It also does not follow the formatting guidelines.