GetDriveName Method

Returns a string containing the name of the drive for a specified path.



  • object
    Required. Always the name of a FileSystemObject.

  • path
    Required. The path specification for the component whose drive name is to be returned.


The GetDriveName method returns a zero-length string ("") if the drive can't be determined.


The GetDriveName method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.

The following example illustrates the use of the GetDriveName method.

function GetDriveLetter(path)
   var fso, s ="";
   fso = new ActiveXObject("Scripting.FileSystemObject");
   s += fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(path)));
Function GetAName(DriveSpec)
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")
   GetAName = fso.GetDriveName(Drivespec)
End Function

Applies To:

FileSystemObject Object

See Also


GetAbsolutePathName Method

GetBaseName Method

GetDrive Method

GetExtensionName Method

GetFile Method

GetFileName Method

GetFileVersion Method

GetFolder Method

GetParentFolderName Method

GetSpecialFolder Method

GetTempName Method