Skip to main content

FileSystemObject.DriveExists method

Table of contents
  1. Syntax
  2. Remarks
  3. Examples

Returns True if the specified drive exists; False if it does not.


object.DriveExists (drivespec)

The DriveExists method syntax has these parts:

Part Description
object Required. Always the name of a FileSystemObject.
drivespec Required. A drive letter or a path specification for the root of the drive.


For drives with removable media, the DriveExists method returns True even if there are no media present. Use the IsReady property of the Drive object to determine if a drive is ready.


The following code illustrates the use of the DriveExists method.

Sub DriveExistsDemo()
    Dim fso As Object, f As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Debug.Print fso.DriveExists("D") 'Result: True
    Debug.Print fso.DriveExists("T") 'Result: False
End Sub

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>