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.
source share