先通过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); }
先通过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); }