UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
> Java - Getting Directory Returns Wrong Directory    
 
   
kruuth
post Aug 6 2015, 08:46 AM
Post#1



Posts: 849
Joined: 30-May 07



When I run this it will not return the right directory:

CODE
public String pullDirectory(){
        //System.out.println(directoryListing.getText());
        String dirString = ".";
        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new java.io.File("."));
        chooser.setDialogTitle("Choose Source Directory");
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setAcceptAllFileFilterUsed(false);
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            dirString = chooser.getCurrentDirectory().toString();
            }
        else {
            dirString = "No Selection ";
            }
        return dirString;      
    }


When I do this, the browsing window will open, but if I navigate to something like "C:\Lists" it will return only C:. If I navigate to something like "C:\Users\Bob\Desktop" it will only return "C:\Users\Bob"

I'm a little new to JAVA. How do I fix this?
Go to the top of the page
 

Posts in this topic



Custom Search


RSSSearch   Top   Lo-Fi    9th December 2019 - 04:46 AM