List all drives : Drive : File Directory Stream C# Examples


C# Examples » File Directory Stream » Drive »

 

List all drives









    
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);
                        }
                }
        }
}
    
   
  
   



Output

C:\ - 32330000 KB
D:\


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» Drive