I am trying to list all files in Windows 7 under C: \ Windows \ System32 \ oobe \ info \ Backgrounds by calling the following:
const string logonScreenBackgroundPath = "C:\\Windows\\System32\\oobe\\info\\Backgrounds"; DirectoryInfo dInfo = new DirectoryInfo(logonScreenBackgroundPath); string[] backgroundFiles = Directory.GetFiles(logonScreenBackgroundPath);
However, I get an exception in the GetFiles call: Could not find part of path "C: \ Windows \ System32 \ oobe \ info \ Backgrounds
I checked that the folder exists and has files, I connected to it on the command line, and everything is fine, but the C # call fails.
Calling GetFiles on C: \ Windows \ System32 \ oobe \ works fine. Nothing is different from the folder attributes between \ oobe and \ info.
After further investigation, this looks like a 64-bit problem. When I create my project for "AnyCpu", the folder will be found without any problems. The problem is that my project should compile for x86, not AnyCpu due to dependencies.
SOLUTION: This appears to be a known issue, and MS has released a fix for it. The problem is with the reconfiguration of the file system.
Now I turn off redirection on the calling thread with the following:
[DllImport("kernel32.dll", SetLastError = true)] public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); IntPtr ptr = new IntPtr(); bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
source share