Forum Stats

  • 3,872,132 Users
  • 2,266,392 Discussions


How to access ShellFolder using a path

886787 Member Posts: 2 Blue Ribbon
edited Sep 7, 2011 11:47AM in Java Desktop Applications

I would like to have the ShellFolder of a given path to browse its content.
	                FileSystemView systemView = FileSystemView.getFileSystemView();
		File homeDirectory = systemView.getHomeDirectory();
		File[] files = systemView.getFiles(homeDirectory,false);
		File home2=new File(homeDirectory.getAbsolutePath());
		File[] files1 = systemView.getFiles(home2, false);
		File[] files2 = home2.listFiles();
		File[] files3 = homeDirectory.listFiles();
When the home is obtained using FileSystemView, everything is fine (I obtain what I expect) in the list appear Computer, Network, ... but when I attempt to recreate the file using a path I obtain a subset of the previous result without Computer, Network, ... It just contains the list of "physical" files on the dirve, all "system" files are not present.

Is there a solution to obtain an instance of the right File object pointing to the homeDirectory or ComputerDirectory or Network Directory giving <u> a path </u> (I don't know which one, this may include clsid) ?



  • 886787
    886787 Member Posts: 2 Blue Ribbon
    Here is a not perfect solution:
    private File createFolderByPath(String path) {
    		File file = getLocalRepository();
    		String[] strings = path.split("/");
    		for (int i = 0; i < strings.length; i++) {
    			String string = strings<em>;<br />
    			file = systemView.getChild(file, string);<br />
    		}<br />
    		return file;<br />
    	}<br />
    <pre class="jive-pre"><code class="jive-code">If someone has a better idea...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
This discussion has been closed.