ASP Drive Object

The Drive object is used to return information about local disk drives or network shared drives.

Instance

Obtain the number of available space of a specified drive
This example demonstrates how to first create a FileSystemObject object, and then use the AvailableSpace attribute to obtain the available space of a specified drive.
Obtain the remaining space capacity of a specified drive
This example demonstrates how to use the FreeSpace space attribute to obtain the remaining space of a specified drive.
Obtain the total capacity of a specified drive
This example demonstrates how to use the TotalSize attribute to get the total capacity of a specified drive.
Obtain the drive letter of a specified drive
This example demonstrates how to use the DriveLetter attribute to get the drive letter of a specified drive.
Obtain the drive type of a specified drive
This example demonstrates how to use the DriveType attribute to get the drive type of a specified drive.
Obtain the file system information of a specified drive
This example demonstrates how to use FileSystem to obtain the file system type of a specified drive.
Is the drive ready?
This example demonstrates how to use the IsReady attribute to check if the specified drive is ready.
Obtain the path of a specified drive
This example demonstrates how to use the Path attribute to obtain the path of a specified drive.
Obtain the root folder of a specified drive
This example demonstrates how to use the RootFolder attribute to obtain the root folder of a specified drive.
Obtain the serial number of a specified drive
This example demonstrates how to use the Serialnumber attribute to obtain the serial number of a specified drive.

Drive object

The Drive object is used to return information about local disk drives or network shared drives. The Drive object can return information about the file system, remaining capacity, serial number, volume label, and other information of the drive.

Note:Information about the contents of the drive cannot be returned through the Drive object. To achieve this, please use the Folder object.

To operate the properties of the Drive object, we need to create an instance of the Drive object through the FileSystemObject object. First, create a FileSystemObject object, and then illustrate the Drive object through the GetDrive method or Drives property of the FileSystemObject object.

The following example uses the GetDrive method of the FileSystemObject object to illustrate the Drive object and uses the TotalSize property to return the total capacity (in bytes) of the specified drive (c):

<%
Dim fs,d
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set d=fs.GetDrive("c:")
Response.Write("Drive " & d & ":")
Response.Write("Total size in bytes: " & d.TotalSize)
set d=nothing
set fs=nothing
%>

Output:

Drive c: Total size in bytes: 5893563398

Properties of the Drive object

Property Description
AvailableSpace Returns the available space capacity on the specified drive or network shared drive to the user.
DriveLetter Returns an uppercase letter that identifies local drives or network shared drives.
DriveType Returns the type of the specified drive.
FileSystem Returns the file system type used by the specified drive.
FreeSpace Returns the remaining space capacity on the specified drive or network shared drive to the user.
IsReady Returns true if the specified drive is ready; otherwise, returns false.
Path Returns an uppercase letter followed by a colon, used to indicate the path name of the specified drive.
RootFolder Returns a folder object that represents the root folder of the specified drive.
SerialNumber Return the serial number of the specified drive.
ShareName Return the network share name of the specified drive.
TotalSize Return the total capacity of the specified drive or network shared drive
VolumeName Set or return the volume name of the specified drive