DriveInfo Class

Provides access to information on a drive.

Syntax

Declaration

[ComVisible(true)]
public sealed class DriveInfo

Inheritance Hierarchy

Inherited Members

System.Object

, , , , ,

Constructors summary

Provides access to information on the specified drive.

Properties summary

Indicates the amount of available free space on a drive, in bytes.

Gets the name of the file system, such as NTFS or FAT32.

Gets the drive type, such as CD-ROM, removable, network, or fixed.

Gets a value that indicates whether a drive is ready.

Gets the name of a drive, such as C:.

Gets the root directory of a drive.

Gets the total amount of free space available on a drive, in bytes.

Gets the total size of storage space on a drive, in bytes.

Gets or sets the volume label of a drive.

Methods summary

Retrieves the drive names of all logical drives on a computer.

Returns a drive name as a string.

Constructors

  • DriveInfo(String)

    Provides access to information on the specified drive.

    public DriveInfo(string driveName)

    Parameters

    • driveName

      A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z'. A null value is not valid.

    Exceptions

    • The drive letter cannot be null.

    • The first letter of driveName is not an uppercase or lowercase letter from 'a' to 'z'.

      -or-

      driveName does not refer to a valid drive.

Properties

  • AvailableFreeSpace

    Indicates the amount of available free space on a drive, in bytes.

    public long AvailableFreeSpace { get; }

    Property Value

    • The amount of free space available on the drive, in bytes.

    Exceptions

  • DriveFormat

    Gets the name of the file system, such as NTFS or FAT32.

    public string DriveFormat { get; }

    Property Value

    • The name of the file system on the specified drive.

    Exceptions

  • DriveType

    Gets the drive type, such as CD-ROM, removable, network, or fixed.

    public DriveType DriveType { get; }

    Property Value

    • One of the enumeration values that specifies a drive type.

  • IsReady

    Gets a value that indicates whether a drive is ready.

    public bool IsReady { get; }

    Property Value

    • true if the drive is ready; false if the drive is not ready.

  • Name

    Gets the name of a drive, such as C:.

    public string Name { get; }

    Property Value

    • The name of the drive.

  • RootDirectory

    Gets the root directory of a drive.

    public DirectoryInfo RootDirectory { get; }

    Property Value

    • An object that contains the root directory of the drive.

  • TotalFreeSpace

    Gets the total amount of free space available on a drive, in bytes.

    public long TotalFreeSpace { get; }

    Property Value

    • The total free space available on a drive, in bytes.

    Exceptions

  • TotalSize

    Gets the total size of storage space on a drive, in bytes.

    public long TotalSize { get; }

    Property Value

    • The total size of the drive, in bytes.

    Exceptions

  • VolumeLabel

    Gets or sets the volume label of a drive.

    public string VolumeLabel { get; set; }

    Property Value

    Exceptions

Methods

  • GetDrives()

    Retrieves the drive names of all logical drives on a computer.

    public static DriveInfo[] GetDrives()

    Returns

    • An array of type DriveInfo that represents the logical drives on a computer.

    Exceptions

  • ToString()

    Returns a drive name as a string.

    public override string ToString()

    Returns

    • The name of the drive.

    Overrides

Details

Namespace

System.IO

Assembly

System.IO.FileSystem.DriveInfo.dll