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:
Astronomic Storage Sizes ...
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.