所以我工作的工作简单的.NET程序,并打了一下一个奇怪的障碍我想不通的。该应用程序使用它增加了应用程序下拉菜单的配置文件。然而,在它添加到菜单,它确实system.io.file.exists以验证该文件存在,至少在创建菜单的时间。
So I am working on a simple .NET program for work and hit a bit of a weird roadblock I can't figure out. The application makes use of a configuration file which adds applications to a dropdown menu. However, before it's added to the menu, it does a system.io.file.exists to verify that the file exists, at least at the time the menu is created.
不过,System.IO.File.Exists(@C: WINDOWS SYSTEM32 SnippingTool.exe)返回false,但可执行文件是存在的。同样,stikynot.exe也返回false。在system32目录下的其他文件返回true(如记事本)。我可以FILESTAT这些应用程序,但我的.NET程序就不能阅读它们,system.io.file.exists返回false。我已经检查各种权限,没有运气。这似乎是孤立的几个应用程序,但我不知道为什么。
However, System.IO.File.Exists(@"C:WindowsSystem32SnippingTool.exe") returns false, but the executable is there. Likewise, stikynot.exe also returns false. Other files in the system32 directory return true(like notepad). I can filestat these applications, but my .net program just can't read them them and system.io.file.exists returns false. I have checked various permissions with no luck. It seems to be isolated to a few applications, but I am not sure why.
推荐答案
这是64位Windows的功能。
That's a feature of 64 bit Windows.
在64,你有两个文件夹使用系统文件: SYSTEM32 和 Syswow64资料
In x64 you have two folders with system files: system32 and SysWOW64.
如果你把东西的 SYSTEM32 ,它会被所有的 64位应用程序可见。 Syswow64资料是有兼容性的原因 - 任何东西放在那里将是可见的 32位(!原文如此)的应用
If you put anything in system32, it will be seen by all 64 bit applications. SysWOW64 is there for compatibility reasons - anything put there will be visible by 32 bit (sic!) apps.
所以就.NET而言,该文件不存在。它适用于记事本,因为NOTEPAD.EXE是present在这两个目录中。
So as far as .NET is concerned, the file does not exist. It works for notepad, because notepad.exe is present in both of those directories.
您可以测试这种行为。创建在目录中的文本文件,而不是其他,并检查其存在。然后改变你的项目配置(右键单击解决方案 - >配置管理器)。x86和x64之间,享受结果
You can test this behaviour. Create a text file in one of the directories, but not the other and check for its existence. Then change your project configuration (right click on solution -> Configuration Manager) between x86 and x64 and enjoy the result.
相关推荐
最新文章