List all drives : Drive « File Directory Stream « C# / CSharp Tutorial






using System;
using System.IO;

static class MainClass
{
    static void Main(string[] args)
    {
        foreach (DriveInfo drive in DriveInfo.GetDrives())
        {
            try
            {
                Console.WriteLine(
                    "{0} - {1} KB",
                    drive.RootDirectory,
                    drive.AvailableFreeSpace / 1024
                    );
            } catch (IOException) {
                Console.WriteLine(drive);
            }
        }
    }
}
C:\ - 32330000 KB
D:\








15.14.Drive
15.14.1.List all drives
15.14.2.Get all logical drives
15.14.3.DriveInfo: name, type, format and available free space
15.14.4.DriveInfo App