Environment.GetLogicalDrives 메서드

정의

이 컴퓨터에서 논리 드라이브의 이름을 검색합니다.

public:
 static cli::array <System::String ^> ^ GetLogicalDrives();
public static string[] GetLogicalDrives();
static member GetLogicalDrives : unit -> string[]
Public Shared Function GetLogicalDrives () As String()

반품

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")를 반환합니다.

적용 대상