How to find all files, including hidden and system files

I need to create a complete list of files and subdirectories in a directory.

DirectoryInfo.GetFiles() does NOT find all files; hidden files, at a minimum, are missing.

(There may also be a permission problem, since I cannot look inside some directories using Windows Explorer, although I work as an administrator. For example, "C: \ System Volume Information" cannot be entered.)

I am using C #, Windows XP Pro

+4
source share
5 answers

DirectoryInfo.GetFiles() returns all files (except those for which you do not have permissions).

At the very least, it definitely includes hidden files, as shown by this person who almost exactly addresses this issue .

Do you have a specific example of a file that appears elsewhere but not on this list?

+6
source

Weighing in at this late date, GetFiles does NOT always return all files, and I also did not understand why. Here is one way to play (at least on 64-bit Windows 7 Home, running as an administrator and using C # with Visual Studio 2010).

Install the FTDI EXECUTABLE installer drivers from here ( http://www.ftdichip.com/Drivers/D2XX.htm )

The following files will be installed on Windows \ System32:

 -ftbusui.dll -ftcserco.dll -ftd2xx.dll -FTLang.dll -ftserui2.dll 

The following code:

 String[] files = Directory.GetFiles(Environment.SystemDirectory, "f*.*", SearchOption.TopDirectoryOnly); 

returns ftd2xx.dll, but not the other four files.

Changing the searchPattern parameter to *. * or simply using:

 GetFiles(Environment.SystemDirectory) 

returns ftd2xx.dll, but not the other four files.

None of the files are hidden, and all five have the same owner permissions and permissions. All five files are displayed in Windows Explorer and in the command prompt window.

In fact, the following returns false:

 File.Exists(@"c:\Windows\System32\ftbusui.dll") 

and four files are not displayed in the OpenFileDialog dialog box. Running the executable as administrator does not matter, and disabling UAC does not help.

+3
source

Must. Try searching in a different directory, create a manually hidden file and see if it appears in the search results.

+2
source

DirectoryInfo.GetFiles() returns all files, including hidden files.

+2
source

As others have noted, DirectoryInfo.GetFiles() gets all the files. Thus, it looks like you might run into a resolution problem.

+1
source

All Articles