This documentation is archived and is not being maintained.
Environment::GetLogicalDrives Method
Visual Studio 2010
Returns an array of string containing the names of the logical drives on the current computer.
Assembly: mscorlib (in mscorlib.dll)
Return Value
Type: array<System::String>An array of strings where each element contains the name of a logical drive. For example, if the computer's hard drive is the first logical drive, the first element returned is "C:\".
| Exception | Condition |
|---|---|
| IOException | An I/O error occurs. |
| SecurityException | The caller does not have the required permissions. |
The following example shows how to display the logical drives of the current computer using the GetLogicalDrives method.
// Sample for the Environment::GetLogicalDrives method using namespace System; int main() { Console::WriteLine(); array<String^>^drives = Environment::GetLogicalDrives(); Console::WriteLine( "GetLogicalDrives: {0}", String::Join( ", ", drives ) ); } /* This example produces the following results: GetLogicalDrives: A:\, C:\, D:\ */
- EnvironmentPermission
for full access to the resource protected by this permission. Associated enumeration: PermissionState::Unrestricted
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: