My.Computer.FileSystem.Drives Property

Returns a read-only collection of all available drive names.

' Usage
Dim value As System.Collections.ObjectModel.ReadOnlyCollection(Of System.IO.DriveInfo) = My.Computer.FileSystem.Drives
' Declaration
Public ReadOnly Property Drives As System.Collections.ObjectModel.ReadOnlyCollection(Of System.IO.DriveInfo)

Property Value

System.Collections.ObjectModel.ReadOnlyCollection (of System.IO.DriveInfo)

Exceptions

This property throws no exceptions.

Remarks

This property returns all logical drives.

Tasks

The following table lists examples of tasks involving the My.Computer.FileSystem.Drives property.

To

See

Determine a drive's volume label

How to: Determine a Drive's Volume Label in Visual Basic

Determine a drive's format

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

Determine a drive's type

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

Determine a drive's total space

How to: Determine a Drive's Total Space in Visual Basic

Determine a drive's free space

How to: Determine a Drive's Physical Free Space in Visual Basic

Determine a drive's root directory

How to: Determine a Drive's Root Directory in Visual Basic

Example

This example displays the available drive names in a message box.

Dim getInfo As System.IO.DriveInfo()
getInfo = System.IO.DriveInfo.GetDrives
For Each info As System.IO.DriveInfo In getInfo
    MsgBox(info.name)
Next

Requirements

Namespace:Microsoft.VisualBasic.MyServices

Class:FileSystemProxy (provides access to FileSystem)

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type

Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

Yes

Windows Service

Yes

Web Site

Yes

Permissions

The following permission may be necessary:

Permission

Description

FileIOPermission

Controls the ability to access files and folders. Associated enumeration: Unrestricted.

For more information, see Code Access Security and Requesting Permissions.

See Also

Reference

My.Computer.FileSystem Object

System.Collections.ObjectModel.ReadOnlyCollection<T>

System.IO.DriveInfo

FileSystem.Drives

Other Resources

File, Directory, and Drive Properties in Visual Basic