CSharp examples for File IO:Directory
Get the Total Free Space on a Drive
using System;//from w ww . jav a 2 s . c om using System.IO; static class MainClass { static void Main(string[] args) { DriveInfo drive1 = new DriveInfo("c:/"); Console.WriteLine(drive1.AvailableFreeSpace / 1024); foreach (DriveInfo drive in DriveInfo.GetDrives()) { try { Console.WriteLine( "{0} - {1} KB", drive.RootDirectory, drive.AvailableFreeSpace / 1024 ); } catch (IOException) // network drives may not be available { Console.WriteLine(drive); } } } }