Retorna uma string que contém o nome da pasta pai do último componente em um caminho especificado.
Sintaxe
object.GetParentFolderName(path)
Argumentos:
FileSystemObject.Nota:
O método GetParentFolderName só funciona na string de caminho fornecida. Ele não tenta resolver o caminho nem verifica a existência do caminho especificado.
O exemplo a seguir ilustra o uso do método GetParentFolderName.
Exemplo 1:
Function GetTheParent(DriveSpec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName(DriveSpec)
End Function
' Usage
Dim parentFolder
parentFolder = GetTheParent("C:\Path\To\Your\File.txt")
' Output: C:\Path\To\Your
Exemplo 2:
Function GetTheParent(DriveSpec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName(DriveSpec)
End Function
' Usage
Dim parentOfDirectory
parentOfDirectory = GetTheParent("C:\Path\To\Your\Folder\SubFolder")
' Output: C:\Path\To\Your\Folder