Could not find part of path "C: \\ Windows \\ System32 \\ oobe \\ info \\ Backgrounds

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); 
+4
source share
2 answers

I am sure that your problem is related to this article , which describes what is wrong and how to fix this problem. There is a fix on the site that you can install and should fix the problem. Hope this helps!

+7
source

Based on Icemanind's answer, if you are compiling a .net application, the solution that worked for us is to change the target platform (from AnyCPU) to x64.

No need to install a fix.

0
source

All Articles