Method: DriveExists for FileSystemObject
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Methods > Method: DriveExists for FileSystemObject
Method: DriveExists for FileSystemObject
Checks whether a drive exists.
bDriveExists = Object.DriveExists(DriveSpec)
| Object | FileSystemObject Object with this method |
| DriveSpec | String Specifies the drive or the drive path. |
| bDriveExists | Boolean If the drive exists, the value is True. If the drive does not exist, the value is False. The value is also True for the removable media, if no disk is in the drive. |
The following example checks whether a disk drive exists:
Function DriveStatus(sDrv) Dim fso, sOutput Set fso = CreateObject("Scripting.FileSystemObject") If fso.DriveExists(sDrv) Then sOutput = ("Drive " & sDrv & " exists.") Else sOutput = ("Drive " & sDrv & " doesn't exist.") End If DriveStatus = sOutput End Function