Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans Current Project File Path

In Netbeans what is the correct way to get the file path of the currently Opened Project. In the module I am developing I need to acquire the path of the Project for a FileChooser however most of what I tried simply returned the path of the module it is executing from. Is their a way to get the path of the Project that the method is run from?

like image 714
kdgwill Avatar asked Nov 05 '22 08:11

kdgwill


1 Answers

Try to get a Project instance via lookup and then

        private String getProjectDirectory(final Project project) {
            try {
                FileObject projectDirectory = project.getProjectDirectory();
                return FileUtil.toFile(projectDirectory).getAbsolutePath();
            } catch (Exception e) {
                //ignore the exception
                return null;
            }
        }
like image 54
Ben Avatar answered Nov 09 '22 15:11

Ben