"Drive" Class - Disk Drive

This section provides a tutorial example on how to use the Drive class that represents a disk drive of a file system. Drive class is provided in the Scripting Runtime DLL, scrrun.dll.

"Drive": A class representing a disk drive of the file system. It offers the following methods and properties:

Here is a sample ASP page to show the above properties:

<script language="vbscript" runat="server">
'  drive_test.asp
'  Copyright (c) 1999 by Dr. Herong Yang
'  This program shows how to use the Drive class.
'
   response.write("<html><body>")
   response.write("<b>Tests on the Drive class</b>:<br/>")
   ' Creating a FileSystemObject object
   set fs = CreateObject("Scripting.FileSystemObject")
   set ds = fs.Drives
   response.write("List of drives:<br/>")
   ' Display all drives and their properties
   for each d in ds
      response.write("Drive Letter = " & d.DriveLetter & "<br/>")
      response.write("Drive Type = " & d.DriveType & "<br/>")
      response.write("Is Ready = " & d.IsReady & "<br/>")
      response.write("Path = " & d.Path & "<br/>")
      response.write("Share Name = " & d.ShareName & "<br/>")
      if d.IsReady then 
         response.write("File System = " & d.FileSystem & "<br/>")
         response.write("Serial Number = " & d.SerialNumber & "<br/>")
         response.write("Volume Name = " & d.VolumeName & "<br/>")
         response.write("Total Size = " & d.TotalSize & "<br/>")
         response.write("Free Space = " & d.FreeSpace & "<br/>")
      end if
   next
   response.write("</body></html>")
</script>

Output:

Tests on the Drive class:
List of drives:
Drive Letter = C
Drive Type = 2
Is Ready = True
Path = C:
Share Name = 
File System = NTFS
Serial Number = 1545214583
Volume Name = New Volume
Total Size = 9697603584
Free Space = 4838227968
Drive Letter = D
Drive Type = 4
Is Ready = False
Path = D:
Share Name = 

Note that:

Last update: 2002.

Table of Contents

 About This Book

 ASP (Active Server Pages) Introduction

 IIS (Internet Information Services) 5.0

 MS Script Debugger

 VBScript Language

 ASP Built-in Run-time Objects

 ASP Session

 Creating and Managing Cookies

 Managing Sessions with and without Cookies

scrrun.dll - Scripting Runtime DLL

 What Is scrrun.dll?

 "Dictionary" Class - Collection of Key-Value Pairs

 "FileSystemObject" Class - File System

"Drive" Class - Disk Drive

 "Folder" Class - File Folder

 "File" Class - File Folder

 "TextStream" Class - Input or Output Stream

 Managing Response Header Lines

 Calculation Speed and Response Time

 ADO (ActiveX Data Object) DLL

 Working with MS Access Database

 Guest Book Application Example

 References

 PDF Printing Version