DriveInfo: name, type, format and available free space : Drive « File Directory Stream « C# / CSharp Tutorial






using System;
using System.IO;

static class MainClass
{
    static void Main(string[] args)
    {
        FileInfo file = new FileInfo("c:\\test.txt");

        // Display drive information.
        DriveInfo drv = new DriveInfo(file.FullName);

        Console.Write("Drive: ");
        Console.WriteLine(drv.Name);
        
        if (drv.IsReady)
        {
            Console.Write("Drive type: ");
            Console.WriteLine(drv.DriveType.ToString());
            Console.Write("Drive format: ");
            Console.WriteLine(drv.DriveFormat.ToString());
            Console.Write("Drive free space: ");
            Console.WriteLine(drv.AvailableFreeSpace.ToString());
        }

    }
}
Drive: c:\
Drive type: Fixed
Drive format: NTFS
Drive free space: 33105936384








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