简体   繁体   中英

How do you change file permissions to stop Vista from writing to a file in the VirtualStore directory?

When my program first installs it places a file in the user's AppData directory, and the program then will periodically write to that file. The problem is in Vista the writes are not made to the file in the user's AppData directory, they are made to a copy of that file in the “VirtualStore/ProgramData” directory. The original file in the user's AppData directory never gets changed, it seems when the program runs it only has access to the file inside the VirtualStore directory.

Is there a way from inside a C# app to change the permissions on that file so that my program will write to the original one in the AppData directory and not the one in the VirtualStore directory?

Thanks,

Jeff

The UAC documentation “Designing UAC Applications for Windows Vista” should help you solve this.

It sounds to me like you need to add an application manifest.

When your application includes an application manifest with a "requestedExecutionLevel" value specified, Vista's virtualization of the registry and file system will be switched off.

Take a look at Create and Embed an Application Manifest (UAC) for specifics.

If you haven't previously tested your application under non-admin conditions, you might find that you need to make some code changes after you turn off Vista's virtualization.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM