繁体   English   中英

该系统找不到指定的路径

[英]The system cannot find the path specified

我试图使用C#从位置%system%\\ drivers \\计算一些文件的sha1哈希值。 我知道文件位于确切的位置但是当我使用时

FILE.Exists("c:\\Windows\\System32\\Drivers\\1394ohci.sys") 

它总是回报错误。

C:\Users\administrator>dir c:\Windows\System32\drivers\1394ohci.sys
 Volume in drive C has no label.
 Volume Serial Number is 5A4F-1E60

 Directory of c:\Windows\System32\drivers

11/21/2010  08:53 AM           229,888 1394ohci.sys
               1 File(s)        229,888 bytes
               0 Dir(s)  19,521,245,184 bytes free


C:\Users\administrator>fciv -sha1 c:\Windows\system32\drivers\1394ohci.sys
//
// File Checksum Integrity Verifier version 2.05.
//
c:\windows\system32\drivers\1394ohci.sys\*
        Error msg  : The system cannot find the path specified.
        Error code : 3

我甚至尝试了文件上的fciv.exe,它也生成相同的输出。 我尝试将命令作为administratror运行,但它没有帮助。

我做了很多网络搜索,但没有任何效果。 请帮忙,让我知道如何解决这个问题。

感谢您的帮助。 谢谢,

如果我正确理解您的问题,那么您需要查看文件系统重定向器

%windir%\\ System32目录是为64位应用程序reserved的。 创建64位版本的DLL时,大多数DLL文件名都没有更改, 因此32位版本的DLL存储在不同的目录中 WOW64使用文件系统重定向器隐藏了这种差异。

在大多数情况下, 只要32位应用程序尝试访问%windir%\\ System32,就会将访问权限重定向到%windir%\\ SysWOW64 对%windir%\\ lastgood \\ system32的访问权限被重定向到%windir%\\ lastgood \\ SysWOW64。 对%windir%\\ regedit.exe的访问权限被重定向到%windir%\\ SysWOW64 \\ regedit.exe。

如果您可以尝试那个,那么页面底部还有一些小样本

string system32Directory = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32");
if(Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
{
// For 32-bit processes on 64-bit systems, %windir%\system32 folder
// can only be accessed by specifying %windir%\sysnative folder.
system32Directory = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "sysnative");
}

正如其他人所提到的,这是文件系统重定向器正在工作。 解决方法是在文件路径中使用sysnative替换system32

这也让我感到疯狂,找到简单的解决方法花了太多工作。 我一直在使用高级脚本和复杂,模糊的切向相关解决方案登陆页面。 所以我想我会分享“简易模式”。

以管理员模式运行程序。

来自http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx

如果在尝试确定指定文件是否存在时发生任何错误,则Exists方法返回false。 在引发异常的情况下会发生这种情况,例如传递带有无效字符或字符太多的文件名,磁盘失败或丢失,或者调用者没有读取文件的权限。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM