Name
FileSystemObject.GetFolder Method
Syntax
oFileSysObj.GetFolder(FolderPath)
oFileSysObjUse: Required
Data Type: FileSystemObject object
A FileSystemObject object.
FolderPathUse: 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
FolderPathcan be an absolute or relative path.If
FolderPathis 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
FolderPathdoesn’t exist, an error occurs.
Programming Tips and Gotchas
You should first use GetAbsolutePathName to create the required
FolderPathstring.If
FolderPathincludes 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
FolderPathis the path to a valid folder, you should call the FolderExists method to verify thatFolderPathexists.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
Setstatement to assign the Folder object reference to a local object variable.
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access