views:

82

answers:

3

Java has a Properties class that is nice for saving basic configuration information, e.g. a gui setting you would like to have persist from one session to the next. It saves and retrieves key value pairs as I recall and is quite simple to use. I have been looking for an analogue of this in C# but without success. Am I missing it?

If there isn't one, is there anything above and beyond simply saving / reading a custrom text file for saving simple application setting? (Measure of "above and beyond" being simplicity).

+2  A: 

System.Configuration.ConfigurationManager is what you're looking for. It allows you to save/read key/value pairs to the app.config/web.config file for your application.

If you want to store user specific data, you can also check out the settings file: Using Settings in C#

Justin Niessner
+1  A: 

Yes. Search for

Properties.Settings
Adrian Serafin
+3  A: 

If you create a standard .NET project and go to Properties, then go to Settings, then click to create one, you should be able to accomplish what you want there. That will allow you use Properties.Settings which is good for persisting user settings.

If you want application wide settings, the app.config (compiled as MyApplication.exe.config) is the way to go. You can access these settings via ConfigurationManager.AppSettings (requires System.Configuration assembly reference)

JeffN825
I see that the settings in question are actually created as a class named Settings in the namespace ProjectNameSpace.Properties where ProjectNameSpace is the namespace of my project.
John Robertson