Environment.GetLogicalDrives Yöntem

Tanım

Bu bilgisayardaki mantıksal sürücülerin adlarını alır.

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

Döndürülenler

String[]

Mantıksal sürücü adlarını temsil eden dize dizisi.

Özel durumlar

G/Ç hatası oluşur.

Çağıranın gerekli izinleri yok.

Örnekler

Aşağıdaki örnekte, yöntemini kullanarak geçerli bilgisayarın mantıksal sürücülerinin nasıl görüntüleneceği gösterilmektedir 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:\
'

Açıklamalar

Windows GetLogicalDrives, "<drive letter>:\" (örneğin, "C:\") biçimindeki optik sürücüler veya çıkarılabilir medya cihazları dahil olmak üzere belirli bir makinedeki tüm erişilebilir sürücülerin adlarını döndürür. Unix'te, belirli bir makineye bağlanan tüm dosya sistemi bağlama noktalarının yollarını döndürür (örneğin, "/home/user", "/media/usb").

Şunlara uygulanır