O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

FileSystemObject.GetParentFolderName Method

Syntax

                  oFileSysObj.GetParentFolderName(Path)
oFileSysObj

Use: Required

Data Type: FileSystemObject object

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. In other words, if Path ends in a filename, the method returns the path to the folder containing that file. If Path ends in a folder name, the method returns the path to that folder’s parent.

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 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 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 Getx Name methods of the FileSystemObject object, the GetParentFolderName method is more a string parsing and manipulation routine than an object-related routine.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required