-1

I want to check by program if a flash drive (pen drive) is plugged into my computer. If I can detect that a flash drive is plugged in then all the contents will be copied to my computer invisibly. I've a idea to do that. But I think it's pretty bad.

String allDrives[] = {"A","B",....,"Z"};
while(true){
   for(String drive : allDrives){
      if(drive exists){
          Do the required task
      }   
   }
}

Is there any better idea to do that? Any help is appreciated.

Anika Tuba
  • 11
  • 4
  • Please try searching harder first to avoid duplicate questions. – user1133275 Mar 06 '15 at 15:46
  • Possible duplicate of [How can I get list of all drives but also get the corresponding drive type (removable,local disk, or cd-rom,dvd-rom... etc)?](http://stackoverflow.com/questions/3542018/how-can-i-get-list-of-all-drives-but-also-get-the-corresponding-drive-type-remo). Technically isn't a dupe, since no one has asked this exact question. However, it shows no research effort at all, and the questions that appear are very related. – Nic Mar 06 '15 at 15:51

1 Answers1

0

Use the proper way to list drives, then copy the files, maybe someone with more points can close this as a duplicate.

Community
  • 1
  • 1
user1133275
  • 2,642
  • 27
  • 31