Introduction

The DriveInfo class in C# is one of the important classes in the System.IO namespace since it can get the system information like drive type, space, etc.., We will discuss this class in detail with a sample application.

How to Get the Drives?

The drives in the system can be used by the GetDrives method in the DriveInfo class. It will return a collection of DriveInfo objects.

DriveInfo[] driveInfo = DriveInfo.GetDrives();

Drives

DriveInfo Class

The System.IO namespace has a class that helps the users interact with the system to get the file details, directory details, and system information. The DriveInfo class is a read-only class and can be used to get details about the drives.

It has the following properties in the DriveInfo class. Let us see them one by one.

DriveInfo driveInfo = new DriveInfo("Drive Name");

The drive name has to be passed as a constructor to get the details about the drive in the system.

Conclusion

The DriveInfo class is one of the very useful classes to scale the drive information. The source code is attached to the article.