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.GetFolder Method

Syntax

                  oFileSysObj
                  .GetFolder(FolderPath)
oFileSysObj

Use: Required

Data Type: FileSystemObject object

A FileSystemObject object.

FolderPath

Use: Required

Data Type: String

A path to the required folder.

Return Value

A Folder object.

Description

Returns a reference to a Folder object.

Rules at a Glance

  • FolderPath can be an absolute or relative path.

  • If FolderPath is a share name or network path, GetFolder ensures that the drive or share exists as part of the process of returning the Folder object.

  • If any part of FolderPath doesn’t exist, an error occurs.

Programming Tips and Gotchas

  • You should first use GetAbsolutePathName to create the required FolderPath string.

  • If FolderPath includes a network drive or share, you could use the DriveExists method to confirm the required drive is available prior to calling the GetFolder method.

  • Since GetFolder requires that FolderPath is the path to a valid folder, you should call the FolderExists method to verify that FolderPath exists.

  • The GetFolder method allows you to directly obtain an object reference to a particular folder. You can also use the Item property of the Folders collection object for cases in which you must navigate the filesystem to reach a particular folder, or for those cases in which you’re interested in enumerating the subfolders belonging to a particular folder.

  • You must use the Set statement to assign the Folder object reference to a local object variable.

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