Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 884633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:46:48+00:00 2026-05-15T12:46:48+00:00

The File.listFiles() method lists the contents of a folder. On windows however, when you

  • 0

The File.listFiles() method lists the contents of a folder. On windows however, when you call the method on your root drive, it also yields some – in lack of a better phrase – “virtual” folders (Like “Documents and Settings”, which got replaced by “Users” in recent windows versions).

If you then call listFiles() for one of those “virtual” folders, it always returns null. And that’s where my problem is, as I want to recursively walk through all the folders. I need a way to filter those folders out and preferably not by checking their names…

There are also some additional folders, that the normal user doesn’t see (like “System Volume Information” or the Recycle-bin folder for that drive), and I would be glad to find a method of filtering those out as well without blacklisting the names.

Unfortunately, those folders behave just like real ones. What I’m looking for is something like a File.isSystemFolder()-method.

I’m really thankful for any advice

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:46:49+00:00Added an answer on May 15, 2026 at 12:46 pm

    You can filter those hidden system folders by testing if File#isHidden() returns true.

    I am not sure about “virtual” folders. I think distinguishing them is only possible with the New IO 2 which is coming in Java 7. I’ll have to check that first yet on a Vista/Win7 machine (I’m currently on XP).


    Update: I did a quick test at our 2K3 Server, the Documents and Settings by default also returns true for File#isHidden() while Users don’t. You could make use of that as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote recursive method to calculate folder size: private static long calcSize(File dir) {
In Java you can do File.listFiles() and receive all of the files in a
One-Liner to list TXT-files. import java.io.File; import java.io.FilenameFilter; ... files = dir.listFiles(new FilenameFilter() {
I have the following decleration: private Dictionary<string, Dictionary<string, File>> listFiles = new Dictionary<string,Dictionary<string,File>>(); How
I need to write a tool that lists the classes that call methods of
When I pass File file to a method I'm trying to get its full
I have two classes in my REST API wrapeer: Wrapper::Folder and Wrapper::File . Each
I am working on some kind of file sharing program which is written in
I have a method which zips up 5 files. It produces a zip file
Is there an idiomatic Scala solution to obtain only the file names from File.listFiles

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.