DriveInfo.RootDirectory
using System;
using System.IO;
class MainClass {
static void Main(string[] args) {
if (args.Length == 1) {
DriveInfo drive = new DriveInfo(args[0]);
Console.Write("Free space in {0}-drive (in kilobytes): ", args[0]);
Console.WriteLine(drive.AvailableFreeSpace / 1024);
return;
}
foreach (DriveInfo drive in DriveInfo.GetDrives()) {
Console.WriteLine("{0} - {1} KB",drive.RootDirectory,
drive.AvailableFreeSpace / 1024
);
}
}
}
Related examples in the same category