Collection: Drives
- Updated2024-09-12
- 1 minute(s) read
(Collections | FileSystemObject) > Collection: Drives
Collection: Drives
A collection of all Drive objects. You can count drives or access an individual drive using the Drives collection.
The following example generates a collection of all drives:
Function CreateDriveList Dim fso, oMyDrive, oMyDrives, sOutput Set fso = CreateObject("Scripting.FileSystemObject") Set oMyDrives = fso.Drives For Each oMyDrive in oMyDrives sOutput = sOutput & oMyDrive.DriveLetter & VBTab If oMyDrive.DriveType = 3 Then sOutput = sOutput & oMyDrive.ShareName ElseIf oMyDrive.IsReady Then sOutput = sOutput & oMyDrive.VolumeName Else sOutput = sOutput & "[Not ready]" End If sOutput = sOutput & VBCrLf Next CreateDriveList = sOutput End Function