FileSystem.GetDriveInfo(String) 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.
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
- drive
- String
Drive to be examined.
DriveInfo object for the specified drive.
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
is Nothing
or an empty string.
The path exceeds the system-defined maximum length.
The user lacks necessary permissions to view the path.
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.")
For information on the different drive types, see DriveType.
The DriveInfo class models a drive and provides methods and properties to query for drive information. Use DriveInfo to determine what drives are available, and what type of drives they are. You can also query the property to determine the capacity and available free space on the drive.
Προϊόν | Εκδόσεις |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET σχόλια
.NET είναι ένα έργο ανοιχτού κώδικα. Επιλέξτε μια σύνδεση για να παρέχετε σχόλια: