Cannot write to application directory in Program Files

I need to write some files in the application directory that is installed in Program Files. I know that with UAC enabled in Vista and Windows 7, users cannot modify files in this directory. However, I know about UAC virtualization, which was added in Vista, which basically redirects entries to the virtualstore directory. This works fine in Vista, and my files are actually written to this virtual store directory. However, in Windows 7, I am denied access to errors, and my files are not written to this directory at all. What gives?

+4
source share
3 answers

Is it the same binary code or was it compiled (under Win7)?

If your application manifest indicates that it supports Vista, then Vista will also throw an error.

+1
source

I'm not sure what you are trying to do, but you should not write data to the program file directory unless you are updating or modifying the application itself.

I would change the code to write to the right place. Redirecting Vista was just a shred to keep apps from breaking.

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

+2
source

Have you tried using IsolatedStorageFile ?

0
source

Source: https://habr.com/ru/post/1303016/


All Articles