O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Listing Drives

Querying the computer’s drive letters and related information is achieved through the use of the DriveInfo class. To create instances of this type, either use the constructor that takes a drive letter (such as A, B:, or C:\), or use the GetDrives static method to get an array of all the drives on the machine.

Each DriveInfo object provides access to information about the drive represented by the object. This includes things such as the drive type (fixed disk, DVD, and so on), volume labels, free space, and so forth. The following example shows some of this information for all the drives on the machine:

static void Main(){    foreach (var drive in DriveInfo.GetDrives())    {        Console.WriteLine("{0} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required