Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DriveInfo::GetDrives Method ()

 

Retrieves the drive names of all logical drives on a computer.

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)

public:
static array<DriveInfo^>^ GetDrives()

Return Value

Type: array<System.IO::DriveInfo^>^

An array of type DriveInfo that represents the logical drives on a computer.

Exception Condition
IOException

An I/O error occurred (for example, a disk error or a drive was not ready).

UnauthorizedAccessException

The caller does not have the required permission.

This method retrieves all logical drive names on a computer. You can use this information to iterate through the array and obtain information on the drives using other DriveInfo methods and properties. Use the IsReady property to test whether a drive is ready because using this method on a drive that is not ready will throw a IOException.

The following code example demonstrates the use of the DriveInfo class to display information about all of the drives on the current system.

No code example is currently available or this language may not be supported.

SecurityPermission

for calling unmanaged code, such as calling native code with platform invoke or COM interop. Associated enumeration: SecurityPermissionFlag::UnmanagedCode

.NET Framework
Available since 2.0
Return to top
Show:
© 2017 Microsoft