0

I'm working with a small command line application in C#. Is the ConfigurationManager a good solution for this? Is this a configuration I can write to, or is it read only?

This page: http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings.aspx provides a clear indication that I can read data.

My objective is to collect some information via command line prompts and write what's entered into a file the application can use with other commands.

Thanks for the help, I'm new to C# so I'm just figuring this stuff out.

Marc
  • 16,170
  • 20
  • 76
  • 119
Ben
  • 60,438
  • 111
  • 314
  • 488
  • Usefull answer here : http://stackoverflow.com/questions/4216809/configurationmanager-doesnt-save-settings – 2GDev Nov 13 '12 at 13:35

1 Answers1

2

I suggest using the Settings functionality instead of ConfigurationManager - if you wish to read/write user settings, that's the right tool.

The .NET Framework 2.0 allows you to create and access values that are persisted between application execution sessions. These values are called settings. Settings can represent user preferences, or valuable information the application needs to use. For example, you might create a series of settings that store user preferences for the color scheme of an application. Or you might store the connection string that specifies a database that your application uses. Settings allow you to both persist information that is critical to the application outside of the code, and to create profiles that store the preferences of individual users.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • Thanks... when I try to use `Properties.Settings.Default.myColor = Color.AliceBlue;` in my application it says `Properties does not exist in the current context`. I tried adding `using Properties;` but it again did not recognize it. When I'm looking at a documentation page like what you linked to, how can I find out what namespace needs to be included in order to gain access to the mentioned functionality? – Ben Nov 13 '12 at 22:50
  • @Webnet - You need to reference the `System.Windows.Forms` namespace to get access to the `Properties` class. – Oded Nov 14 '12 at 09:21