VBScript » FileSystemObject » GetDrive

Version: 2.0

Syntax:
object.GetDrive(drivename)

This method returns a Drive object corresponding to the drive in a supplied path.

The drivename argument must be in an accepted format:
A drive letter such as, c
A drive letter with a colon such as, c:
A drive letter with a colon and a path such as, c:\hisfolder\herfile

If the drive does not exist or the format is not correct, the GetDrive method will return an error.

Examples

Code:
<%
dim filesys, name, DriveObject
Set filesys = CreateObject("Scripting.FileSystemObject")
name = filesys.GetDriveName("c:\DevGuru\website\VBScript.txt")
Set DriveObject = filesys.GetDrive("c:\DevGuru\website\VBScript.txt")
Response.Write(name)
%>
Output:
"c:"
Explanation:

You also may use the GetDriveName method to obtain the drivename argument.

See Also: