wood burning stoves 2.0*
The moose likes Java in General and the fly likes file.listFiles() returns extra folders compared to Windows Explorer (Windows 7) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "file.listFiles() returns extra folders compared to Windows Explorer (Windows 7)" Watch "file.listFiles() returns extra folders compared to Windows Explorer (Windows 7)" New topic
Author

file.listFiles() returns extra folders compared to Windows Explorer (Windows 7)

Malcolm Storey
Ranch Hand

Joined: Nov 09, 2008
Posts: 31
File method listFiles() returns a list of files and folders, but the folders include some not shown by Windows Explorer. The extra folders all claim to be empty so are no use. Is there any way to filter out those not shown by WE to make the user experience more consistent? (I thought canonicalisation might resolve them but it doesn't.)

For C://, these are the additional ones:
  • $Recycle.Bin - fair enough, though the contents are "repackaged"
  • Config.Msi
  • Documents and Settings
  • Recovery
  • System Volume Information

  • C:\\Users has:
  • Default User

  • and my user has:
  • Application Data
  • Cookies
  • Local Settings
  • NetHood
  • PrintHood
  • Recent
  • SendTo
  • Start Menu
  • Templates


  • Malcolm

    I wouldn't join any Collection with an add() method that would accept me as a parameter
    Ivan Jozsef Balazs
    Rancher

    Joined: May 22, 2012
    Posts: 867
        
        5
    They seem to be special purpose folders, handled by the explorer specially.

    They might be listed in the registry. As if their names were even translated to the local language in a non-English Windows.
    WE can be (and by default is) set to hide the known file extensions.

    It could be a hard task to provide a completely consistent experience...
    Tony Docherty
    Bartender

    Joined: Aug 07, 2007
    Posts: 2176
        
      47
    I suspect these folders all have their hidden flag set, so you could test for that and filter out all hidden folders.
    Malcolm Storey
    Ranch Hand

    Joined: Nov 09, 2008
    Posts: 31
    You're right, but it's not what Windows calls "hidden files, folders and drives", which I already had set to "show". If I turn off "Hide protected operating system files (Recommended)" then WE shows them. Some are access-denied, some are merely shortcuts, but it makes more sense now.

    Presumably isHidden() will pick up those that are simply marked as hidden, as well as system folders.

    Many thanks!
     
    Consider Paul's rocket mass heater.
     
    subject: file.listFiles() returns extra folders compared to Windows Explorer (Windows 7)
     
    Similar Threads
    Program: Change Due/Tendered
    Maven settings.xml file on Windows 7
    Status Bar and Win XP
    Discrepancy in listing of a file using Windows Explorer and JAVA I/O classes
    JTree Explorer with Desktop, My Computer, My Documents, My Network Places etc.