ij.io.DirectoryChooser question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ij.io.DirectoryChooser question

Jon Harman
Hi,

I am using the DirectoryChooser in the following way, see below.

My problem is that if there is more than one non-existent directory in
the path,. the outdir path is not what the user typed.  It has the last
non-existent directory appended after the last existent directory.
So I can't use the mkdirs() to make the intermediate directories.

Is this my mistake?  Any solution?

Jon

        DirectoryChooser odc =
            new DirectoryChooser("Choose the output directory");
        outdir = odc.getDirectory();
        File odir = new File(outdir);
        if(!odir.exists())
        {
            GenericDialog gd = new GenericDialog("Create Directory Dialog");
            gd.addMessage(outdir + " does not exist.  Create?");
            gd.showDialog();

            if (gd.wasCanceled()) return;
            try {
                odir.mkdirs();
            }
            catch (SecurityException e){
              IJ.showMessage("Exception when creating directory:" +
e.getMessage());
              return;
            }
        }