DriveInfo Class
Provides access to information on a drive.
Assembly: mscorlib (in mscorlib.dll)
The DriveInfo type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | AvailableFreeSpace | Indicates the amount of available free space on a drive. |
![]() | DriveFormat | Gets the name of the file system, such as NTFS or FAT32. |
![]() | DriveType | Gets the drive type. |
![]() | IsReady | Gets a value indicating whether a drive is ready. |
![]() | Name | Gets the name of a drive. |
![]() | RootDirectory | Gets the root directory of a drive. |
![]() | TotalFreeSpace | Gets the total amount of free space available on a drive. |
![]() | TotalSize | Gets the total size of storage space on a drive. |
![]() | VolumeLabel | Gets or sets the volume label of a drive. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() | GetDrives | Retrieves the drive names of all logical drives on a computer. |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a drive name as a string. (Overrides Object.ToString.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ISerializable.GetObjectData | Populates a SerializationInfo object with the data needed to serialize the target object. |
The following code example demonstrates the use of the DriveInfo class to display information about all of the drives on the current system.
Imports System Imports System.IO Class Test Public Shared Sub Main() Dim allDrives() As DriveInfo = DriveInfo.GetDrives() Dim d As DriveInfo For Each d In allDrives Console.WriteLine("Drive {0}", d.Name) Console.WriteLine(" File type: {0}", d.DriveType) If d.IsReady = True Then Console.WriteLine(" Volume label: {0}", d.VolumeLabel) Console.WriteLine(" File system: {0}", d.DriveFormat) Console.WriteLine( _ " Available space to current user:{0, 15} bytes", _ d.AvailableFreeSpace) Console.WriteLine( _ " Total available space: {0, 15} bytes", _ d.TotalFreeSpace) Console.WriteLine( _ " Total size of drive: {0, 15} bytes ", _ d.TotalSize) End If Next End Sub End Class 'This code produces output similar to the following: ' 'Drive A:\ ' File type: Removable 'Drive C:\ ' File type: Fixed ' Volume label: ' File system: FAT32 ' Available space to current user: 4770430976 bytes ' Total available space: 4770430976 bytes ' Total size of drive: 10731683840 bytes 'Drive D:\ ' File type: Fixed ' Volume label: ' File system: NTFS ' Available space to current user: 15114977280 bytes ' Total available space: 15114977280 bytes ' Total size of drive: 25958948864 bytes 'Drive E:\ ' File type: CDRom ' 'The actual output of this code will vary based on machine and the permissions 'granted to the user executing it.
- FileIOPermission
for accessing directory information. The class constructor requires this permission. Associated enumeration: PathDiscovery.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.





