0

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.

Kara
  • 6,115
  • 16
  • 50
  • 57
Samuel
  • 29
  • 9
  • What have you tried so far? And are you trying to do this on the server or on a client machine? – xxbbcc Jul 07 '14 at 15:37
  • does [this question](http://stackoverflow.com/questions/715739/looking-for-c-sharp-code-for-detecting-removable-drive-usb-flash) help? – Sam Holder Jul 07 '14 at 15:37
  • Do you wish to read the usb from the client or server? As xxbbcc said you need to show us what you had tried. We're not here to write your app for you. – matt_lethargic Jul 07 '14 at 15:49
  • Where is the USB drive? On the client PC of the person browsing your website? You don't have access to their local resources - it would be a huge security risk. – DaveBeta Jul 07 '14 at 15:50
  • @xxbbcc Hi.I haven't try it out yet as I am trying to get more info about how to do it. But as much as I know, I want to run it on the server but detect it on the client side. Hope you all can give me some suggestions on how to start. – Samuel Jul 07 '14 at 16:09
  • @DaveBeta Hi. The USB drive is on the client PC. – Samuel Jul 07 '14 at 16:12

1 Answers1

1

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);
Bill Sambrone
  • 4,334
  • 4
  • 48
  • 70