c#遍历系统中所有驱动器
思路分析:
首先,通过DriveInfo类的GetDrivers方法得到所有的驱动器信息。
然后,遍历,GetDrives()返回一个DriveInfo数组。
代码:
复制代码 代码示例:
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
Console.WriteLine("Drive: {0}", drive.Name);
Console.WriteLine("Type: {0}", drive.DriveType);
}