Saving user settings in winforms C#

  • Thread starter Thread starter parez
  • Start date Start date
P

parez

Whats the best way of storing user settings and application settings
in a winforms application?

Should i create my own xml files and save it in
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
?

What about the Settings class.? There were examples in vb.net which
lets a user save.

If it is readonly then why is there a save method?
 
Whats the best way of storing user settings and application settings
in a winforms application?

The .NET 2.0 settings classes are pretty good for many uses.
Should i create my own xml files and save it in
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
?

I wouldn't if I were you.
What about the Settings class.? There were examples in vb.net which
lets a user save.

If it is readonly then why is there a save method?

Calling Save() is fine - but it will only save the user settings, not
application settings.

The previously saved settings will be loaded by default next time
they're accessed, assuming you use the auto-generated class
(Settings.settings etc in Visual Studio).

Jon
 
The .NET 2.0 settings classes are pretty good for many uses.


I wouldn't if I were you.



Calling Save() is fine - but it will only save the user settings, not
application settings.

The previously saved settings will be loaded by default next time
they're accessed, assuming you use the auto-generated class
(Settings.settings etc in Visual Studio).

Jon

Yes I am using the Settings.settings file

So if dont write my own xml files how will i save application
settings?
 
Yes I am using the Settings.settings file

So if dont write my own xml files how will i save application
settings?

Do they *have* to be application settings rather than user settings? I
don't know offhand of any easy way of saving application settings,
although there may well be a way somewhere.
 
Yes I am using the Settings.settings file

So if dont write my own xml files how will i save application
settings?

Application settings aren't meant to be changed out in the wild. It's
more of a way for you to store settings instead of hard coding
values.
 
Application settings aren't meant to be changed out in the wild. It's
more of a way for you to store settings instead of hard coding
values.

Thats what i thought.. I have used web.config in asp.net applications
for storing read only appplication configuration stuff..

So I will either have to write my custom xml or save to DB???
 
Thats what i thought.. I have used web.config in asp.net applications
for storing read only appplication configuration stuff..

So I will either have to write my custom xml or save to DB???

Well, the settings mechanism is reasonably extensible - you may find
there's already code you can take.

However, you should ask yourself what distinction you want to draw
between user and application settings beyond the fact that one set is
writable and the other isn't. What harm would it do to make all the
settings user settings?
 
Thats what i thought.. I have used web.config in asp.net applications
for storing read only appplication configuration stuff..

So I will either have to write my custom xml or save to DB???

I think you misunderstand... Settings can be either Application (which
aren't meant to be changed) or User (which can be saved as described
in this thread). If you want the user to be able to change settings,
either diretly or indirectly, you should set them as user settings.
 
Well, the settings mechanism is reasonably extensible - you may find
there's already code you can take.

However, you should ask yourself what distinction you want to draw
between user and application settings beyond the fact that one set is
writable and the other isn't. What harm would it do to make all the
settings user settings?

yea.. i can think in that direction.. thansk..
 
Back
Top