Reputation: 48566
I want to know what is the actual difference between Application and User scope in Settings configuration for vs projects.
Is the only difference the fact that if I select Application, I can't use Settings.MyProperty
as a setter, but I have to use Settings["MyProperty"]
instead?
How would using the User scope affect the program otherwise, if the config file is located at my application root?
Upvotes: 8
Views: 3455
Reputation: 168
Your best bet is to use the 'User' setting because with the newer operating systems Windows doesn't like you reading and writing to files that are local to your executable, this looks suspicious due to the awareness of viruses. So Windows likes you to read and write to designated safe areas which I believe happens in some application data area that the operating system keeps track of. If you set the scope to 'Application' it may try to write this data to the local config file(which is why you need to run with admin privileges) and with the operating systems becoming more locked down there may still be issues doing this. Your app may work in XP like this but anything newer might not work, especially when apps run in the 'c:\Program Files' folders...
Upvotes: 0
Reputation: 273864
User scope means each user gets their own copy, the settings are stored in the users profile folders and your App can Save those settings without Admin privileges.
If you change an Application setting (using Settings["MyProperty"]
) and call Settings.Save() you will have to be running as Admin because the changes are saved to MyApplication.exe.config . And changes apply to all users.
Upvotes: 6