在C#里获取U盘的盘符
using System.IO;
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" File type: {0}", d.DriveType);
}
Console.WriteLine("---------------------");
foreach (DriveInfo d in allDrives)
{
//жU
if (d.DriveType == DriveType.Removable)
{
Console.WriteLine("Drive {0}", d.Name);
}
}
Console.ReadLine();
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" File type: {0}", d.DriveType);
}
Console.WriteLine("---------------------");
foreach (DriveInfo d in allDrives)
{
//жU
if (d.DriveType == DriveType.Removable)
{
Console.WriteLine("Drive {0}", d.Name);
}
}
Console.ReadLine();