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) {
}
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) {
}