locating a directory

Joined
Oct 13, 2008
Messages
1
Reaction score
0
i have written an app that will be run from a USB drive, than inturn will call another application on the usb drive.

i need to be able to determine which drive the application is running from. At the moment i am scanning all hard drives for a particular directory (known to be on the usb stick), when found i have identified the drive that the app is running off.

I am using file listroot's, and then using the output to do a boolean if directory located on drive. do something.

the application works but the problem is that it throws 2 Windows pop-up errors saying "No Disk", i assume it is caused by my boolean trying to evaluate a directory on a drive that isn't actually there. tried a try / catch, which doesn't fix things.

wondering if anyone can please help or point me in the right direction,

many thanks

Michael



this is the code i am using:

for (int i = 0; i < drives.length; i++) {
String location;
String location2;
String ppa = "ppa";
location = (drives.toString()+ ppa);
try {
jTextArea1.append("\n");
boolean exists = (new File(location)).isDirectory();
if (exists) {
jTextArea1.append("\n");
jTextArea1.append(drives.toString());
foundLocation = location;
String torun = location + "\\ABC.exe /Path=C: /AutoReport="+drives.toString();
jTextArea1.append(torun);
Process proc = Runtime.getRuntime().exec(torun);
}
else {}
} catch (Exception ee) {

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,076
Messages
2,570,565
Members
47,201
Latest member
IvyTeeter

Latest Threads

Top