FileSystem.GetDriveInfo(String) Método

Definição

Retorna um objeto DriveInfo para a unidade especificada.Returns a DriveInfo object for the specified drive.

public:
 static System::IO::DriveInfo ^ GetDriveInfo(System::String ^ drive);
public static System.IO.DriveInfo GetDriveInfo (string drive);
static member GetDriveInfo : string -> System.IO.DriveInfo
Public Shared Function GetDriveInfo (drive As String) As DriveInfo

Parâmetros

drive
String

Unidade a ser examinada.Drive to be examined.

Retornos

DriveInfo

Objeto DriveInfo da unidade especificada.DriveInfo object for the specified drive.

Exceções

O caminho não é válido por um dos seguintes motivos: é uma cadeia de tamanho zero, contém apenas espaços em branco, contém caracteres inválidos ou é um caminho de dispositivo (começa com \\.\).The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\.\).

drive é Nothing ou é uma cadeia de caracteres vazia.drive is Nothing or an empty string.

O caminho excede o tamanho máximo definido pelo sistema.The path exceeds the system-defined maximum length.

O usuário não tem as permissões necessárias para exibir o caminhoThe user lacks necessary permissions to view the path

Exemplos

Este exemplo obtém um DriveInfo objeto para a unidade C e o usa para exibir informações sobre a unidade.This example obtains a DriveInfo object for the C drive and uses it to display information about the drive.

Dim getInfo = My.Computer.FileSystem.GetDriveInfo("C:\")
MsgBox("The drive's type is " & getInfo.DriveType)
MsgBox("The drive has " & getInfo.TotalFreeSpace & " bytes free.")

Para obter informações sobre os diferentes tipos de unidade, consulte DriveType .For information on the different drive types, see DriveType.

Comentários

A DriveInfo classe modela uma unidade e fornece métodos e propriedades para consultar informações da unidade.The DriveInfo class models a drive and provides methods and properties to query for drive information. Use DriveInfo para determinar quais unidades estão disponíveis e quais tipos de unidades elas são.Use DriveInfo to determine what drives are available, and what type of drives they are. Você também pode consultar a propriedade para determinar a capacidade e o espaço livre disponível na unidade.You can also query the property to determine the capacity and available free space on the drive.

Aplica-se a

Confira também