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[]

각 요소에 논리 드라이브의 이름이 포함된 문자열의 배열입니다. 예를 들어 컴퓨터의 하드 드라이브가 첫 번째 논리 드라이브일 경우, 반환되는 첫 번째 요소는 "C:\"입니다.

예외

I/O 오류가 발생했습니다.

호출자에게 필요한 사용 권한이 없습니다.

예제

다음 예제에서는 메서드를 사용 하 여 현재 컴퓨터의 논리 드라이브를 표시 하는 방법을 보여 있습니다 GetLogicalDrives .

// 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:\
*/
// 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:\
'

적용 대상