Easily Saving user settings in a c# Windows Forms application

  • Thread starter Thread starter Nevyn Twyll
  • Start date Start date
N

Nevyn Twyll

I understand that I am not supposed to alter the .config file for a program
(accessible through the AppSettings[]).

Is there a System class you could recommend that I could use (or even a
class out there somewhere) to easily load and save custom settings for the
current user? My only thought is to maybe use a datatable with "key" and
"value" columns and serialize it through XML in an IsolatedStorageFile - but
this just seems so lame and inelegant.

Suggestions?

- Nevyn
 
Hello,

Nevyn Twyll said:
I understand that I am not supposed to alter the .config file for a program
(accessible through the AppSettings[]).

Is there a System class you could recommend that I could use (or even a
class out there somewhere) to easily load and save custom settings for the
current user? My only thought is to maybe use a datatable with "key" and
"value" columns and serialize it through XML in an IsolatedStorageFile - but
this just seems so lame and inelegant.

Application/user settings should not be saved into a config file:

http://www.palmbytes.de/content/dotnetlibs/optionslib.htm

HTH,
Herfried K. Wagner
 
Gawelek said:
Why not ?

<snipped>

Gawel

Three reasons off the top of my head, with regard to user settings...

1) Application Upgrades. Do you really want to deal with maintaining user
settings when you push out version 1.1 of your application which includes an
updated app.config file?

2) Shared Systems. An application is typically installed only once
regardless of the number of people using the computer. If you store User A's
preferences in the app.config, User B will wind-up using the same settings
and have the ability to overwrite those settings with their own preferences.
You would essentially be able to store application preferences only - not
user preferences.

3) Security. In a properly secured system, the user is not running with
admin-level privileges and does not have permission to write to the file
system except to very specific places. An application's install folder is
not one of those specific places. This is one of the purposes of the
IsolatedStorage classes: writing to user-specific locations where you are
guaranteed they have the appropriate permissions.

Ryan LaNeve
 
Back
Top