check if file exist on 64 bits system using File.Exists

后端 未结 2 905
慢半拍i
慢半拍i 2020-12-17 16:56

My OS is 64 bits and in the foler C:\\Windows\\SysWOW64 there is a file 111.txt, but there is not the file in c:\\windows\\system32

but the follwoing code return tru

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-17 17:16

    32bit processes see the contents of the C:\Windows\SysWOW64 directory when they ask for the C:\Windows\System32 directory.

    Additionally, when trying to save a file to C:\Windows\System32, it will end up in C:\Windows\SysWOW64.

    However, unless you are writing an installer-type of program, you probably do not want to mess with these directories at all. All the binaries in C:\Windows\System32 are 64bit and not usable from 32bit processes. That's why the request for them is redirected to C:\Windows\SysWOW64 in the first place.

    Edit: If you really want to see the files, use Wow64DisableWow64FsRedirection via PInvoke.

提交回复
热议问题