如果指定的資料夾存在,則傳回 True;如果不存在,則傳回 False。
語法
object.FolderExists(folderspec)
引數:
FileSystemObject 的名稱。下列範例說明 FileExists 方法的用法。
範例 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.