所以我想我会在这里包括最终答案,所以你不必理解这篇文章.非常感谢Simon Mourier抽出时间来解决这个问题.
我的工作代码
try
{
//Get a list of available devices attached to the USB hub
List<string> disks = new List<string>();
var usbDevices = GetUSBDevices();
//Enumerate the USB devices to see if any have specific VID/PID
foreach (var usbDevice in usbDevices)
{
if (usbDevice.DeviceID.Contains(USB_PID) && usbDevice.DeviceID.Contains(USB_VID))
{
foreach (string name in usbDevice.GetDiskNames())
{
//Open dialog to show file names
textbox1.Text = name.ToString();
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以,只需使用GetUSBDevices我原来的问题,然后包括Simon Mourier的回答所显示的两个类,它应该是好的去!
原始问题
我知道之前已经问过这个问题(见这里)但是他们都没有得到确认答案,我已经尝试了所有建议的答案.不幸的是,这些线程已经很久了,我希望有人能在这里给出更好的答案.
到目前为止,我有两个"起点",我将在下面展示.
选项1 :(获取VID/PID但不是驱动器号)
我有一个嵌入式设备,我通过应用程序连接到该设备.我有代码可以成功扫描任何USB设备并检查VID/PID.我成功检测到我的设备,但我不知道如何获取驱动器号.有人可以帮我吗?我觉得我可以添加另一条线,class …