0

The filepath I get here is one directory up. I selected a folder inside workspace in the filechooser. But the filepath i got is one directory up. Can someone please help me find problem

Code:

      if (evt.getSource() == jButtonOutFileBrowse) {
        JFileChooser fc = new JFileChooser();
        fc.setCurrentDirectory(new java.io.File("."));
        fc.setDialogTitle("Select Directory to save your output file");
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        //fc.setAcceptAllFileFilterUsed(false);   //disable all file chooser

        int i = fc.showOpenDialog(this);
        if (i == JFileChooser.APPROVE_OPTION) {
            File f = fc.getCurrentDirectory();
            outFilePath = f.getPath();
            try {
                System.out.println("out filepath:" + outFilePath);
                jTextPaneOutPath.setText(outFilePath);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

Output:

out filepath:F:\workspace

Screenshot of what i chose

0 Answers0