The method File.listFiles()displays the contents of the folder. However, on Windows, when you call a method on your root drive, it also gives some - in the absence of a better phrase - “virtual” folders (for example, “Documents and Settings”, which are replaced by “Users” in recent versions of windows).
File.listFiles()
If you call listFiles () on one of these "virtual" folders, it always returns null. And this is where my problem is, since I want to recursively go through all the folders. I need a way to filter out these folders and preferably not check their names ...
There are also several additional folders that the average user does not see (for example, “System Volume Information” or the recycle bin folder for this drive), and I would be glad to find a way to filter this data like well without blacklisting the names.
Unfortunately, these folders behave like real ones. I am looking for something like a method File.isSystemFolder().
File.isSystemFolder()
I am very grateful for any advice.
You can filter out these hidden system folders by checking if File#isHidden()returns true.
File#isHidden()
true
"" . , New IO 2, Java 7. , Vista/Win7 ( XP).
. 2K3, Documents and Settings true File#isHidden(), . .
, File.isSystemFolder, , " ", JVM, . Balus, - ( , ).
File.isSystemFolder
"" - -, , ? C:\Documents and Settings ( , C:\Users) , ? , , , getCanonicalPath().equals(getAbsolutePath()) ( . .. s).
C:\Documents and Settings
C:\Users
getCanonicalPath().equals(getAbsolutePath())
.
..
, - , , "". , , - , File, , . , , .
File
Source: https://habr.com/ru/post/1752633/More articles:F # or C # for a personal Silverlight project? - c #How to determine column type with PDO? - typesLinking developer page to appStore from iPhone app - urlTDD system under test creation templates (AutoFixture) - tddJQuery - Microsoft JScript runtime error: expected object - jqueryparent> child notation in jquery 1.3 - javascriptIs output caching variable parameters in web forms, understand route parameters? - c #Reset custom form elements (jQuery) - jqueryThe title of the table title looks like a search bar - iosClick event for controls under other controls - eventsAll Articles