I want to store some application settings (eg database server etc). If these settings do not work, or the file is not present, I want to provide a UI to enter the values and save the file.
I have seen many different suggestions including configurationmanager and using the settings properties (in express) and referencing them using
or whatever. I can read the values this way no problem, but cannot save them. I understand that if the settings scope is set to application, they are read-only. User scope settings are read-write. This was confirmed by testing.
So, if I want Read/write settings, what is the best method?
The best method is to use the Configuration classes as they are written. Users should not be able to write to the application settings; those are supposed to be machine wide. Non-admin/power users cannot write to the Program Files directory, so any attempt would throw an exception.
Also, Windows logo compliance dictates that application preferences be stored in the users's local profile. Using the User scope takes care of this automatically.
Microsoft réalise une enquête en ligne pour comprendre votre opinion sur le site Web de Msdn. Si vous choisissez de participer, l’enquête en ligne vous sera présentée lorsque vous quitterez le site Web de Msdn.