Hello-
I am trying to get my app to discover what drives are on my machine.
I have the following code:
private void createDriveList(){
List tempList = Collections.synchronizedList(new ArrayList());
driveList.add("A:/");
driveList.add("B:/");
driveList.add("C:/");
driveList.add("D:/");
driveList.add("E:/");
driveList.add("F:/");
driveList.add("G:/");
driveList.add("H:/");
driveList.add("I:/");
driveList.add("J:/");
driveList.add("K:/");
driveList.add("L:/");
driveList.add("M:/");
driveList.add("N:/");
driveList.add("O:/");
driveList.add("P:/");
driveList.add("Q:/");
driveList.add("R:/");
driveList.add("S:/");
driveList.add("T:/");
driveList.add("U:/");
driveList.add("V:/");
driveList.add("W:/");
driveList.add("X:/");
driveList.add("Y:/");
driveList.add("Z:/");
try{
for(int d=0;d<driveList.size();d++){
String drive=(String)driveList.get(d);
File Drive = new File(drive);
if(Drive.exists()){
if(Drive.isDirectory()&&Drive.canRead())tempList.add(drive);
}
}
driveList= Collections.synchronizedList(new ArrayList());
driveList=tempList;
}catch(Exception x){System.out.println(x.getMessage());}
}
If , one of my drives does not have a disk inserted into it,
Windows gives an error dialog titled "No Disk"
and allows me to continue or cancel.
Is there any way to escape this dialog?
Thanks for your help.