How to: Determine a Drive's Type in Visual Basic

The GetDriveInfo method provides a DriveInfo object that can be queried for information about a drive on a computer. You can use the DriveType property to determine the drive's type. Attempting to access the property without sufficient permission throws a SecurityException exception.

For more information about which drive types are recognized, see DriveType.

To determine the type of a drive

  • Use the DriveType property to determine the type, as illustrated in the following code.

    Dim cdrive As System.IO.DriveInfo
    cdrive = My.Computer.FileSystem.GetDriveInfo("C:\")

Community Additions