C# – Storing User Settings

cnetwindows-vistawindows-xp

Environment.SpecialFolder.CommonApplicationData

*returns "C:\Documents and Settings\All Users\Application Data" under XP that is
writeable for all users

*returns "C:\ProgramData[MyApp]\" under Vista and this is not writeable for regular users

Now why i want CommonFolder ?
Because, an admin will install my software database on XP (or vista) under Admin account, but when user logs back and run my software, the current account will tel my software to look at a different place the database was installed : the user directory in Documents and settings….

so AllUsers (common folder) is common to admin and regular non admin user..

This drives me crazy : where to put my database so it works under Vista and XP ?????
thanks
Jonathan

Best Answer

Are you using an installer to have the admin run? If so, you should be able to use the installer settings, plus a proper assembly/executable manifest to allow the application (regardless of who is running it) the proper permissions to update/modify files in the ProgramData specific to their application.

I run a similar scenario (application installs to Program Files, common data repository installs to ProgramData, user config,save files store to C:\Users) and the manifest and the settings in the WiX installer allowed this to work.