FileSystemProxy.GetDriveInfo(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳 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 指定磁碟機的物件。
例外狀況
該路徑不成立,原因之一是:它是零長度字串;它僅包含空白;它包含無效字元;或者是裝置路徑(以 \\.\ 開頭)。
drive 是 Nothing 空字串。
路徑超過系統定義的最大長度。
使用者缺乏必要的權限來查看路徑。
範例
此範例取得 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 來判斷有哪些硬碟可用,以及它們是什麼類型的硬碟。 你也可以查詢該物業,以判斷硬碟的容量和可用空間。