Home > DeveloperSection > Forums > How to get all drives in PC with .NET using C#
Dag Hammarskjold
Dag Hammarskjold

Total Post:24

Posted on    October-16-2013 7:06 AM

 C# C# 

 1 Reply(s)
 1128  View(s)
Rate this:

How to get all drives in a PC. and types of every drive and free-space of each if any usb device and external hard disk is there

i.e. System-Drive, CD-Drive, DVD-Drive, Removable etc.

lois waisbrooker
lois waisbrooker

Total Post:70

Posted on    October-16-2013 7:58 AM

foreach(var drive in DriveInfo.GetDrives())
    Console.WriteLine("Drive Type: {0}", drive.DriveType);
    Console.WriteLine("Drive Size: {0}", drive.TotalSize);
    Console.WriteLine("Drive Free Space: {0}", drive.TotalFreeSpace);

Don't want to miss updates? Please click the below button!

Follow MindStick