---
title: "How do you use DriveInfo to get information about available drives and their free space?"  
description: "How do you use DriveInfo to get information about available drives and their free space?"  
author: "ICSM Computer"  
published: 2025-05-16  
updated: 2025-05-22  
canonical: https://www.mindstick.com/forum/161631/how-do-you-use-driveinfo-to-get-information-about-available-drives-and-their-free-space  
category: "c#"  
tags: ["c#", "file handling"]  
reading_time: 2 minutes  

---

# How do you use DriveInfo to get information about available drives and their free space?

How do you use `DriveInfo` to get information about available drives and their [free space](https://www.mindstick.com/forum/2012/free-space-in-dropdownlist)?

## Replies

### Reply by Anubhav Sharma

You can use the `System.IO.DriveInfo` class in C# to get information about available drives and their properties such as **name**, **type**, **format**, **total size**, and **[free](https://www.mindstick.com/articles/12963/3-free-things-to-do-in-valletta) [space](https://www.mindstick.com/articles/12954/do-your-electrical-repair-in-your-own-space)**.

## Example: List All Drives and Their Free Space

```cs
using System;
using System.IO;

class Program
{
    static void Main()
    {
        DriveInfo[] allDrives = DriveInfo.GetDrives();

        foreach (DriveInfo drive in allDrives)
        {
            Console.WriteLine($"Drive: {drive.Name}");

            if (drive.IsReady)
            {
                Console.WriteLine($"  Drive type: {drive.DriveType}");
                Console.WriteLine($"  Volume label: {drive.VolumeLabel}");
                Console.WriteLine($"  File system: {drive.DriveFormat}");
                Console.WriteLine($"  Available space to current user: {drive.AvailableFreeSpace / 1024 / 1024} MB");
                Console.WriteLine($"  Total available space: {drive.TotalFreeSpace / 1024 / 1024} MB");
                Console.WriteLine($"  Total size of drive: {drive.TotalSize / 1024 / 1024} MB");
            }
            else
            {
                Console.WriteLine("  Drive not ready.");
            }

            Console.WriteLine();
        }
    }
}
```

## 🔍 Output Sample (Windows)

```plaintext
Drive: C:\
  Drive type: Fixed
  Volume label: System
  File system: NTFS
  Available space to current user: 128736 MB
  Total available space: 128736 MB
  Total size of drive: 249856 MB

Drive: D:\
  Drive not ready.
```

## Useful Properties of `DriveInfo`

| Property | Description |
| --- | --- |
| `Name` | Drive letter (e.g., `C:\`) |
| `DriveType` | Fixed, Removable, Network, etc. |
| `IsReady` | True if the drive is accessible |
| `VolumeLabel` | Name assigned to the drive |
| `DriveFormat` | File system type (NTFS, FAT32, etc.) |
| `AvailableFreeSpace` | Free space available to current user |
| `TotalFreeSpace` | Total free space on the drive |
| `TotalSize` | Total capacity of the drive |


---

Original Source: https://www.mindstick.com/forum/161631/how-do-you-use-driveinfo-to-get-information-about-available-drives-and-their-free-space

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
