问题
I am updating an existing application that is installed via a Setup and Deployment Project.
The old application copied a config and a database file into the application's folder in Program Files during installation. This worked fine on Win 2000 and Win Xp (under a local admin account). In Windows 7, however, not only is this frowned upon, but it essentially doesn't work due to UAC.
So I want to update the application to write its config/data in CommonApplicationData. In the existing Setup and Deployment project, you can easily select some locations as targets for copying files. i.e. Application Folder, User's Desktop, & User's Program Files.
I do not see an analogous means of telling the Setup program to copy to the AppData / CommonApplicationData folders. Does that exist, and if not, are there any simple fixes?
Thanks!
回答1:
Do a Right Click | Add Special Folder | Custom Folder and name it anything you want ( Common Application Data Folder would be good )
In the folder properties grid, change the DefaultLocation attribute to [CommonAppDataFolder].
Add a file to the folder, build and install. You should find your file in C:\ProgramData on Windows 7.
Be advised, I highly reccomend other tools such as InstallShield and WiX over Visual Studio Deployment Projects. The tool is very limited in what it can do and you will eventually hit a brick wall.
来源:https://stackoverflow.com/questions/3562151/writing-to-appdata-from-a-setup-deployment-project