現在のコンピュータの論理ドライブの名前を格納している文字列の配列を返します。
Public Shared Function GetLogicalDrives() As String()
[C#]
public static string[] GetLogicalDrives();
[C++]
public: static String* GetLogicalDrives() __gc[];
[JScript]
public static function GetLogicalDrives() : String[];
戻り値
各要素に論理ドライブの名前を格納している文字列の配列。たとえば、コンピュータのハード ディスク ドライブが最初の論理ドライブの場合、返される先頭の要素は "C:\" です。
例外
例外の種類 | 条件 |
---|---|
IOException | I/O エラーが発生しました。 |
SecurityException | 呼び出し元に、必要なアクセス許可がありません。 |
使用例
' Sample for the Environment.GetLogicalDrives method
Imports System
Class Sample
Public Shared Sub Main()
Console.WriteLine()
Dim drives As [String]() = Environment.GetLogicalDrives()
Console.WriteLine("GetLogicalDrives: {0}", [String].Join(", ", drives))
End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'GetLogicalDrives: A:\, C:\, D:\
'
[C#]
// Sample for the Environment.GetLogicalDrives method
using System;
class Sample
{
public static void Main()
{
Console.WriteLine();
String[] drives = Environment.GetLogicalDrives();
Console.WriteLine("GetLogicalDrives: {0}", String.Join(", ", drives));
}
}
/*
This example produces the following results:
GetLogicalDrives: A:\, C:\, D:\
*/
[C++]
// Sample for the Environment::GetLogicalDrives method
#using <mscorlib.dll>
using namespace System;
int main() {
Console::WriteLine();
String* drives[] = Environment::GetLogicalDrives();
Console::WriteLine(S"GetLogicalDrives: {0}", String::Join(S", ", drives));
}
/*
This example produces the following results:
GetLogicalDrives: A:\, C:\, D:\
*/
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- EnvironmentPermission (アクセス許可が保護するリソースへのフル アクセス) PermissionState.Unrestricted (関連する列挙体)