Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Malcolm Storey
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  •  
    Ivan Jozsef Balazs
    Rancher
    Posts: 972
    5
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 2878
    59
    • 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 40
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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!
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic