Metodo FolderExists

Restituisce True se il file specificato esiste. In caso contrario, restituisce False.

Sintassi

object.FolderExists(folderspec)

Argomenti:

  • Object: obbligatorio. Sempre il nome dell'oggetto FileSystemObject.
  • Folderspec: obbligatorio. Percorso assoluto della cartella la cui esistenza deve essere determinata.

Nell'esempio seguente viene illustrato l'uso del metodo FileExists.

Esempio 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.