DriveInfo::GetDrives Method ()
.NET Framework (current version)
Retrieves the drive names of all logical drives on a computer.
Assembly: mscorlib (in mscorlib.dll)
| 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.
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
Available since 2.0
Show: