简体   繁体   English

找不到路径的一部分 'C:\\Windows\\System32\\oobe\\info\\Backgrounds

[英]Could not find a part of the path 'C:\\Windows\\System32\\oobe\\info\\Backgrounds

I'm trying to list all files on Windows 7 under C:\Windows\System32\oobe\info\Backgrounds by calling the folowing:我正在尝试通过调用以下命令列出 C:\Windows\System32\oobe\info\Backgrounds 下 Windows 7 上的所有文件:

const string logonScreenBackgroundPath = "C:\\Windows\\System32\\oobe\\info\\Backgrounds";
DirectoryInfo dInfo = new DirectoryInfo(logonScreenBackgroundPath);
string[] backgroundFiles = Directory.GetFiles(logonScreenBackgroundPath);

However I get an exception on the GetFiles call: Could not find a part of the path 'C:\Windows\System32\oobe\info\Backgrounds但是,我在 GetFiles 调用中遇到异常:找不到路径的一部分 'C:\Windows\System32\oobe\info\Backgrounds

I verified the folder exists and has files, I cd to it on the command prompt and all is well, but the c# call fails.我验证了该文件夹存在并且有文件,我在命令提示符下 cd 到它,一切都很好,但是 c# 调用失败。

Calling GetFiles on C:\Windows\System32\oobe\ works fine though.在 C:\Windows\System32\oobe\ 上调用 GetFiles 可以正常工作。 Nothing different as far as folder attributes go between \oobe and \info. \oobe 和 \info 之间的文件夹属性 go 没有什么不同。

After further investigation this looks like a 64-bit issue.经过进一步调查,这看起来像是一个 64 位问题。 When I build my project for "AnyCpu" the folder is found with no issues.当我为“AnyCpu”构建我的项目时,发现该文件夹没有问题。 Problem is my project has to compile for x86 and not AnyCpu due to dependencies.问题是由于依赖关系,我的项目必须为 x86 而不是 AnyCpu 编译。

SOLUTION: Looks like this is a known issue and MS has issued a hotfix for it.解决方案:看起来这是一个已知问题,MS 已针对它发布了修补程序。 The problem is due to filesystem redirection.问题是由于文件系统重定向。

I now disable 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);

I am pretty sure your problem is related to this article which describes what's wrong and how to fix the problem.我很确定您的问题与本文有关,该文章描述了问题所在以及如何解决问题。 There is a hotfix available from the site that you can install and should fix your issue.该站点提供了一个修补程序,您可以安装该修补程序,并且应该可以解决您的问题。 I hope this helps!我希望这有帮助!

Based on the answer from Icemanind, if you're compiling a .net application, a solution that worked for us is to change your platform target (from AnyCPU) to x64.根据 Icemanind 的回答,如果您正在编译 .net 应用程序,对我们有用的解决方案是将您的平台目标(从 AnyCPU)更改为 x64。

No need to install a hotfix.无需安装修补程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到文件 'c:\\windows\\system32\\inetsrv\\xxx.xlsx' - Could not find file 'c:\windows\system32\inetsrv\xxx.xlsx' 拒绝访问路径“ C:\\ Windows \\ System32 \\” - Access to the path 'C:\Windows\System32\ is denied 访问路径 'c:\windows\system32\inetsrv\config\' 被拒绝 - Access to the path 'c:\windows\system32\inetsrv\config\' is denied File.Move错误-System.IO.FileNotFoundException:找不到文件'c:\\ windows \\ system32 \\ inetsrv - File.Move Error - System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv ASP零:System.IO.FileNotFoundException:找不到文件'c:\\ windows \\ system32 \\ inetsrv \\ log4net.config' - ASP Zero :System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\log4net.config' C#错误Windows启动时,对路径'C:\\ Windows \\ system32 \\ Com \\ dmp'的访问被拒绝 - C# Error Access to the path 'C:\Windows\system32\Com\dmp' is denied When Windows Startup .NET CORE 3 Windows 服务的基本路径返回 C:\Windows\System32,但实际文件夹为 D:\MyCustomService - .NET CORE 3 The base path of a Windows Service is returning C:\Windows\System32, But actual folder is D:\MyCustomService GoogleWebAuthorizationBroker-拒绝访问路径'C:\\ Windows \\ system32 \\ config \\ systemprofile' - GoogleWebAuthorizationBroker - Access to the path 'C:\Windows\system32\config\systemprofile' is denied 如何在 C# 中获取 Windows\system32\config\systemprofile\AppData\Local\ 文件夹路径? - How to get Windows\system32\config\systemprofile\AppData\Local\ folder path in C#? Windows窗体程序找不到mdb文件(C:\ windows \ system32 \ qbcdb.mdb) - Windows Form program can not find mdb file (C:\windows\system32\qbcdb.mdb)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM