Environment.GetLogicalDrives Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves the names of the logical drives on this computer.
public:
static cli::array <System::String ^> ^ GetLogicalDrives();
public static string[] GetLogicalDrives ();
static member GetLogicalDrives : unit -> string[]
Public Shared Function GetLogicalDrives () As String()
An array of strings representing the logical drive names.
An I/O error occurs.
The caller does not have the required permissions.
The following example shows how to display the logical drives of the current computer using the GetLogicalDrives method.
// 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:\
'
On Windows, GetLogicalDrives
returns the names of all accessible drives on a particular machine, including any optical drives or removable media devices, in the form "<drive letter>:\" (for example, "C:\"). On Unix, it returns the paths of all filesystem mount points mounted on a particular machine (for example, "/home/user", "/media/usb").
Comentarios de .NET
.NET es un proyecto de código abierto. Seleccione un vínculo para proporcionar comentarios: