Name
FileSystemObject.GetDriveName Method
Syntax
oFileSysObj.GetDriveName (Path)
-
oFileSysObj Use: Required
Data Subtype: FileSystemObject object
Any object variable returning a FileSystemObject object.
-
Path Use: Required
Data Subtype: String
A path specifier.
Return Value
A Variant of subtype String.
Description
Returns the drive name of a given path.
Rules at a Glance
If the drive name can’t be determined from the given path, a zero-length string (“”) is returned.
Programming Tips & Gotchas
For local and mapped drives, GetDriveName appears to look for the colon as a part of the drive’s name to determine whether a drive name is present. For network drives, it appears to look for the computer name and drive name.
GetDriveName is really a string-parsing method rather than a filesystem method. In particular, it does not verify that the drive name that it extracts from
Pathactually exists on the system.Pathcan be a network drive or share.
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