简体   繁体   中英

I want to detect a usb device via asp.net C# web page

I am trying to use thumb drive for my asp.net project. I got ask a question beforehand but this is a new question that I will like to know.

Firstly, I will like to know how to detect USB drives. Example: It will print something like USB detected.

Next, to read file from the USB.

Since the USB drive is on the client's PC, you need to use pure client based code to do this. You need javascript since you are running this in a web context. I haven't used this before, but this may be what you are looking for:

https://developer.chrome.com/apps/app_usb

chrome.usb.getDevices(enumerateDevicesOptions, callback);


function onDeviceFound(devices) {
this.devices=devices;
if (devices) {
  if (devices.length > 0) {
    console.log("Device(s) found: "+devices.length);
  } else {
    console.log("Device could not be found");
  }
} else {
  console.log("Permission denied.");
}
}

chrome.usb.getDevices({"vendorId": vendorId, "productId": productId}, onDeviceFound);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM