Wrong currentDirectory with JFileChooser
I'm working on this program that has to get the names of the pictures in a folder and save some text files in another folder. When i try to get the path to the directory the pictures are in, using JFileChooser, the getCurrentDirectory() returns the folder that contains the picture folder instead of the folder chosen in the dialog. Ex:
I choose the folder C:/Documents/Images
The returned string is C:/Documents
When I change the SelectionMode and choose a file there's no problem in returning the right path, but i want to use this for saving too, and there might not be any files in that folder.
j = new JFileChooser();
String path = j.getCurrentDirectory();
System.out.println("Current directory: "+path);
My solution has been to add the name of the folder to path, but the picture folder might not have the same name everytime.
My next question is what to do when i have the right directory and wants to run through the files in there? The files are numbered, but starts somewhere in the 150's and goes on till the 190's, missing some of the numbers.
My solution to this has been to run from the first number to the last number, but it would be more efficient to leave all the blank numbers out and just look at the actual files.
Hope some of you might be able to help me on these.