現在接続されている論理ドライブ(A:~Z:)を取得する方法を記載します。
取得方法には、幾つかあります。
Directoryクラスを使用して論理ドライブを取得する
1 2 3 4 5 6 |
Dim drives As String() = System.IO.Directory.GetLogicalDrives() ' 取得した論理ドライブ名をすべて表示する For Each d As String In drives Console.WriteLine(d) Next |
Environmentクラスを使用して論理ドライブを取得する
1 2 3 4 5 6 |
Dim drives As String() = System.Environment.GetLogicalDrives() ' 取得した論理ドライブ名をすべて表示する For Each d As String In drives Console.WriteLine(d) Next |
DriveInfoクラスを使用して論理ドライブを取得する
1 2 3 4 5 6 |
Dim drives As System.IO.DriveInfo() = System.IO.DriveInfo.GetDrives() ' 取得した論理ドライブ名をすべて表示する For Each d As System.IO.DriveInfo In drives Console.WriteLine(d.Name) Next |