FolderExists Method
Returns True if a specified folder exists; False if it does not.
Syntax
object.FolderExists(folderspec)
Arguments:
- Object: Required. Always the name of a
FileSystemObject
. - Folderspec: Required. An absolute path to the folder whose existence is to be determined.
The following example illustrates the use of the FileExists
method.
Example 1:
Function CheckFolderExistence(fldr)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(fldr) Then
msg = fldr & " exists."
Else
msg = fldr & " doesn't exist."
End If
CheckFolderExistence = msg
End Function
' Usage
Dim folderPath
folderPath = "C:\1"
bExists = CheckFolderExistence(folderPath)
'bExists now holds C:\1 exists. if the folder exists, else It will have C:\1 doesn’t exists.