Jason
Jason

Reputation: 1441

Can't write to application directory in Program Files

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?

Upvotes: 5

Views: 2413

Answers (3)

Gopher
Gopher

Reputation: 927

Have you tried to use IsolatedStorageFile?

Upvotes: 0

TWA
TWA

Reputation: 12816

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.

Upvotes: 3

Henk Holterman
Henk Holterman

Reputation: 273219

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.

Upvotes: 1

Related Questions