FolderExists 메소드

지정된 폴더가 있는 경우 True를 반환하고, 없는 경우 False를 반환합니다.

구문

object.FolderExists(folderspec)

인수:

  • Object: 필수. 항상 FileSystemObject의 이름입니다.
  • Folderspec: 필수. 폴더가 존재하는지 확인할 절대 경로입니다.

다음 예에서는 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.