我想使用C#访问计算机上逻辑驱动器上的信息。我应该如何做到这一点?谢谢!
对于大多数信息,您可以使用DriveInfo类。
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); } } }