如何在 C# 中检索磁盘信息?

2023-12-12

我想使用 C# 访问计算机上逻辑驱动器的信息。我应该如何实现这个目标?谢谢!


对于大多数信息,您可以使用驱动器信息 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.
            Console.WriteLine(drive.Name);
            if (drive.IsReady) Console.WriteLine(drive.TotalSize);
        }
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 C# 中检索磁盘信息? 的相关文章

随机推荐