I'm writing a software which will run on Windows 7. I'm listing installed services, getting service's image path locations and checking if service file exists.(Dll or Exe).
I'm checking file locations with File.Exist(File_Path)
. For some files, it returns false
even if file path is true
, file exists and I have rights to Access that file.
I know that even if that file exists, if the user don't have the rights to Access it File.Exist(File_Path)
returns false.
For example, it returns true for the file C:\\Windows\\System32\\appmgmts.dll
but it returns false for the file C:\\Windows\\System32\\audiosrv.dll
And when I look user permissions for these 2 files under the Windows explorer, they are exactly same. But File.Exist(File_Path)
returns different answers for these files.
I'm running Visual Studio, and Exe file as an Administrator.
Please give me some advices for this strange behavior.
当我在x86配置中执行File.Exists时,我得到的结果是相同的,但是当我64岁时,这两个文件返回true,并且在网上发现SysWOW64中您搜索的File.Exists时,请查看此问题以获取更多信息: 使用File.Exists检查文件是否在64位系统上存在
I fixed a similar issue that occurred while checking files over a mapping that I created with my domain credentials. I was debugging VS as an Administrator. I was able to navigate through Windows Explorer to the file but not with VS.
I solved the problem when I closed VS Admin mode and started it normally back again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.