FileSystemProxy.GetDriveInfo(String) 方法

定義

回傳 DriveInfo 指定硬碟的物件。

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

參數

drive
String

開車去接受檢查。

傳回

DriveInfo 指定磁碟機的物件。

例外狀況

該路徑不成立,原因之一是:它是零長度字串;它僅包含空白;它包含無效字元;或者是裝置路徑(以 \\.\ 開頭)。

driveNothing 空字串。

路徑超過系統定義的最大長度。

使用者缺乏必要的權限來查看路徑。

範例

此範例取得 DriveInfo C 磁碟的物件,並用它來顯示關於磁碟機的資訊。

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

關於不同硬碟類型的資訊,請參見 DriveType

備註

該類別建模 DriveInfo 硬碟並提供查詢磁碟資訊的方法與屬性。 用 DriveInfo 來判斷有哪些硬碟可用,以及它們是什麼類型的硬碟。 你也可以查詢該物業,以判斷硬碟的容量和可用空間。

適用於

另請參閱