Can't write to application directory in Program Files

安稳与你 提交于 2019-12-22 08:51:23

问题


I need to write to some files in the application directory which is installed under Program Files. I know that with UAC enabled on Vista and Windows 7, users can't modify files in this directory. However, I'm aware of the UAC Virtualization that was added in Vista which basically redirects writes to the virtualstore directory . In Vista this works great and my files are actually written to this virtualstore directory. However, on Windows 7 I am getting access denied errors and my files are not written to this directory at all. What gives?


回答1:


Is it the exact same binary or was it re-compiled (under Win7)?

If your app's manifest indicates that it is Vista-aware than Vista would also give an error.




回答2:


I'm not sure what you are trying to do, but you should not be writing data in the program files directory unless you are upgrading or modifying the application itself.

I would change the code to write to the correct location. The Vista redirect was just a kludge to keep applications from breaking.

Always use the Environment.GetFolderPath method to get system paths.




回答3:


Have you tried to use IsolatedStorageFile?



来源:https://stackoverflow.com/questions/2373058/cant-write-to-application-directory-in-program-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!