There are two ways to drive a driver, primarily to get information about the drives:
First, use FileSystemObject to obtain information about the drive
1, the FileSystemObject object obtains the drive information the method as follows table:
Method |
Description/Format/annotation |
Driveexists |
Checks whether the specified drive exists, returns true if it exists, or returns false. |
Object. Driveexists (DRIVESPEC) |
object specifies the name of the FileSystemObject object. DRIVERSPEC Specifies the drive letter or the full path specified. |
Getdrive |
Returns the Drive object that corresponds to the drive in the specified path. |
Object. Getdrive Drivespec |
object specifies the name of the FileSystemObject object. DRIVERSPEC Specifies the drive letter, which can be either C or C: or C:. It can also be any specified network share (\computerxsharey). |
GetDriveName |
Returns a string containing the drive name in the specified path. |
Object. GetDriveName (PATH) |
object specifies the name of the FileSystemObject object. Path and returns the drive name of its component. If the drive cannot be determined, the GetDriveName method returns a 0 length string (""). |
2, the FileSystemObject object and drive-related properties are as follows:
Drivers property: Returns a collection of drives composed of all Drive objects on the local machine. Removable media drives are displayed in the Drive collection, whether or not they are inserted into the media.
Second, use the Drive object property to get drive information
Property |
Description |
AvailableSpace |
Returns the amount of free space for a specified drive or network share for the user. |
DriveLetter |
Returns a local drive or network share number. If the specified drive is not associated with a drive letter, the DriveLetter property returns a 0-length string (""). |
DriveType |
Returns a value that describes the type of the specified drive: 0 for unknown type, 1 for removable disk, 2 for fixed disk, 3 for network share, 4 for CD-ROM, 5 for RAM disk. |
FileSystem |
Returns the type of file system used by the specified drive, with the available return types including FAT, NTFS, and CDFS. |
FreeSpace |
Returns the amount of free space for a specified drive or network share for the user. The FreeSpace property is essentially the same as the value returned by the AvailableSpace property. For computer systems that support quotas, there are differences between the two returned values. |
IsReady |
Checks whether the specified drive is ready, returns True if it is ready, or returns FALSE. |
Path |
Returns the path to the specified file, folder, or drive. For a drive, the path does not contain a root directory. For example, the C drive path is C:, not C:. |
RootFolder |
Returns a Folder object that represents the root of the specified drive. Using this Folder object, you can access all files and folders for the specified drive. |
Seialnumber |
Returns the decimal sequence number used to uniquely identify a disk volume. Use the Seralnumber property to ensure that the correct disk is inserted in the removable media drive. |
ShareName |
Returns the network share name of the specified drive. If the drive is not a network drive, the ShareName property returns a 0 length string ("" _). |
TotalSize |
Returns the total number of bytes for a drive or network share. |
VolumeName |
Sets or returns the volume label for the specified drive. |
Iii. Example 1 (drive/1.asp): Lists the drive letters, total bytes, and available bytes of all drives on the current computer, with the following code:
<% @ language="vbscript" %>
<body>
<%
Dim fso,d
Set fso=server.CreateObject("Scripting.FileSystemObject")
%>
<table align="center" border="1" cellspacing="5" width="50%">
<caption><b>本计算机驱动器列表(共<%=fso.drives.Count %>个)</b></center>
<tr bgcolor="#caeeff"><th>驱动器</th><th>总空间</th><th>可用空间</th>
<% for Each d In fso.Drives %>
<tr><td><%=d.DriveLetter %>盘</td><td><%=d.TotalSize %>字节</td><td><%=d.AvailableSpace %>字节</td>
<% next %>
</body>
The results of the test.
See the full set of ASP Getting started tutorials