Environment.GetLogicalDrives メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
このコンピューター上の論理ドライブの名前を取得します。
public:
static cli::array <System::String ^> ^ GetLogicalDrives();
public static string[] GetLogicalDrives();
static member GetLogicalDrives : unit -> string[]
Public Shared Function GetLogicalDrives () As String()
返品
論理ドライブ名を表す文字列の配列。
例外
I/O エラーが発生しました。
呼び出し元に必要なアクセス許可がありません。
例
次の例は、 GetLogicalDrives メソッドを使用して現在のコンピューターの論理ドライブを表示する方法を示しています。
// 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:\
*/
// Sample for the Environment.GetLogicalDrives method
open System
let drives = Environment.GetLogicalDrives()
String.concat ", " drives
|> printfn "\nGetLogicalDrives: %s"
// This example produces the following results:
// GetLogicalDrives: A:\, C:\, D:\
' Sample for the Environment.GetLogicalDrives method
Class Sample
Public Shared Sub Main()
Console.WriteLine()
Dim drives As [String]() = Environment.GetLogicalDrives()
Console.WriteLine("GetLogicalDrives: {0}", [String].Join(", ", drives))
End Sub
End Class
'
'This example produces the following results:
'
'GetLogicalDrives: A:\, C:\, D:\
'
注釈
Windowsでは、GetLogicalDrives は、光学式ドライブやリムーバブル メディア デバイスを含む、特定のコンピューター上のすべてのアクセス可能なドライブの名前を "<drive letter>:\" (例: "C:\") で返します。 Unix では、特定のマシンにマウントされているすべてのファイルシステム マウント ポイントのパス ("/home/user"、"/media/usb" など) が返されます。