Reputation: 2898
I started out with my application writing the config to the registry like I did years back with UAC wasn't around.
Turned out this wasn't a good idea so I moved to the app.config
file and found that this is having issues as well with UAC.
The configuration I have for the application is machine specific; individual users do not have their own configuration and the rest of the apps including the service all drive off the single configuration file.
If I try updating this file in the program files\myapp folder it gets denied.
What is everyone else doing for a scenario like this where there needs to be a single configuration file?
I should also mention that this configuration needs to be updated from within my applications.
Upvotes: 1
Views: 1719
Reputation: 18013
I would use the Common Application Data folder, this is where most new applications store data which works with UAC.
You can get this with the following code:
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
To view all options for special folders you can check this link:
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
The most common options would be the following:
Application Data - The directory that serves as a common repository for application-specific data for the current roaming user.
Common Application Data - The directory that serves as a common repository for application-specific data that is used by all users.
Local Application Data - The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user.
Upvotes: 2
Reputation: 7146
I had a similar need with a WPF application. What I do is the following:
I started out using the .NET ConfigurationManager, but I switched over to a plain old XML files because it was simpler and my requirements were basic.
Upvotes: 0
Reputation: 13864
Any machine-wide configuration files should be stored in:
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
Files in Program Files shouldn't be modified except when the application is installed/updated.
Upvotes: 0