FileSystemObject.GetParentFolderName Method (VB6)

Named Arguments

Yes

Syntax

oFileSysObj.GetParentFolderName(Path)

oFileSysObj

Use: Required

Data Type: FileSystemObject object

Any object variable returning a FileSystemObject object.

Path

Use: Required

Data Type: String

A path specifier.

Return Value

A String.

Description

Returns the folder name immediately preceding the last element of a given path.

Rules at a Glance

  • If the parent folder name can't be determined from Path, a zero-length string ("") is returned.

  • Path can be a relative or an absolute reference.

Programming Tips and Gotchas

  • GetParentFolderName doesn't verify that any element of Path exists.

  • Path can be a network drive or share.

  • GetParentFolderName assumes that the last but one element of the string that isn't part of a drive specifier is the parent folder. It makes no other check than this. As with all the GetxName methods of the FileSystemObject object, the GetParentFolderName method is more a string parsing and manipulation routine than an object-related routine.

See Also

Folder.ParentFolder Property

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.