HOW TO GET ALL DRIVES IN PC WITH .NET USING C#

Dag Hammarskjold

Total Post:24

Points:168
Posted by  Dag Hammarskjold
C# 
C#
 1512  View(s)
Ratings:
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.

  1. lois waisbrooker

    Post:70

    Points:494
    Re: How to get all drives in PC with .NET using C#

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!