c# - 该系统找不到指定的路径

标签 c# windows windows-7 sha1

我正在尝试使用 C# 为位置 %system%\drivers\中的某些文件计算 sha1 哈希值。我知道文件位于确切位置但是当我使用

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

它总是返回 false。

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,它也生成了相同的输出。我尝试以管理员身份运行该命令,但没有帮助。

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

感谢您的帮助。 谢谢,

最佳答案

如果我正确理解您的问题,那么您需要查看 File System Redirector

The %windir%\System32 directory is reserved for 64-bit applications. Most DLL file names were not changed when 64-bit versions of the DLLs were created, so 32-bit versions of the DLLs are stored in a different directory. WOW64 hides this difference using a file system redirector.

In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64. Access to %windir%\lastgood\system32 is redirected to %windir%\lastgood\SysWOW64. Access to %windir%\regedit.exe is redirected to %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");
}

关于c# - 该系统找不到指定的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8775841/

相关文章:

windows - 如何使用 PowerShell 2.0 递归删除整个目录?

windows-7 - Batch ~dp0 不适用于管理员权限?

c# - 映射的网络驱动器,File.Exists 奇怪的行为

c# - 非平凡数据类型的预定义常量

java - 如何在按 "*"时停止扩展无限 SWT 树

.net - TimeZoneInfo 和 CultureInfo 的 System.DateTime 和缓存

windows-7 - 将 () 绑定(bind)到 Windows 7 中的 IPv6 地址失败,错误代码::WSAEADDRNOTAVAIL (10049)

c# - 数据流的 block 设计受阻

c# - 将文件从 Angular 发送到 .NET Core

c++ - 将 VARIANT 转换为...?