ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods







METHOD:  FileSystemObject.GetDrive

object.GetDrive(drivename)

This method returns the drive object that is specified by the drivename argument.

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

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

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

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:"