Export (0) Print
Expand All

FileSystem.GetDriveInfo Method

Returns a DriveInfo object for the specified drive.

Namespace:  Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static DriveInfo GetDriveInfo(
	string drive
)

Parameters

drive
Type: System.String

Drive to be examined.

Return Value

Type: System.IO.DriveInfo
DriveInfo object for the specified drive.

ExceptionCondition
ArgumentException

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 \\.\).

ArgumentNullException

drive is Nothing or an empty string.

PathTooLongException

The path exceeds the system-defined maximum length.

SecurityException

The user lacks necessary permissions to view the path

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.

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.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft