• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to distinguish directory Library/Pictures from files programatically?  RSS feed

 
Daniel B. Davis
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Windows 7 Libraries such as 'Library\Documents', or 'Library\Pictures' are not showing up as Directories. I am using java 1.8. Until I corrected my usage by copying the full path from File Explorer, they did not even appear to exist. The full Path I am using is: "C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Libraries\Pictures.library-ms", where <user> has been replaced by my actual user name. In the code below:
// distinguish files from directories
public void getFile(String s) {
System.out.println("getFile entered, arg: "+s);
File f = new File(s);
if (f.exists()) {
if (f.isDirectory())
getDir(f);
else {
processFile(f);
}
} else {
System.out.println("not exists: "+f.getPath());
}
}
the statement 'if (f.isDirectory...' fails to register that it is a directory. Earlier, the exists test failed,
causing me to find the full path name now being used. But now the exists test passes, but the directory test fails.
Is there a way to distinguish these Library entities from files?

 
Guillermo Ishi
Ranch Hand
Posts: 789
C++ Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I read you, you're having trouble seeing a certain directory. Does the code work with any directory all? Root directory? Does it return an error that you can look up? If you step through it do you see it execute at all?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!