leo leo - 1 year ago 82
C# Question

How do I retrieve disk information in C#?

I would like to access information on the logical drives on my computer using C#. How should I accomplish this? Thanks!

Answer Source

For most information, you can use the DriveInfo class.

using System;
using System.IO;

class Info {
    public static void Main() {
        DriveInfo[] drives = DriveInfo.GetDrives();
        foreach (DriveInfo drive in drives) {
            //There are more attributes you can use.
            //Check the MSDN link for a complete example.
            if (drive.IsReady) Console.WriteLine(drive.TotalSize);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download