I am writing a program that need to store some configuration information. I thought XML would be a good choice, but I do not want to learn XML in C# from scratch.
Could you recommend good ways/classes handling this task?
Just use the built-in .NET configuration system! What's wrong with that??
For that, add a reference to System.Configuration
to your project, and have a good look at the ConfigurationManager
class in that namespace.
Starting with Visual Studio 2005, you can also define application- or user-scoped settings in a visual designer inside VS - check out Application Settings Overview on MSDN for this (those work for Winforms and console apps). Those settings are stored in your app.config
/web.config
for the application-scoped settings, and in a separate user.config
file in a directory accessible to the user account for the user-scoped settings. Those can be manipulated and updated at runtime using standard .NET classes (from the System.Configuration
namespace).
While I agree that "re-inventing the wheel" is not a good idea, the .NET System.Configuration class is abominably difficult to use for such a simple task.
I needed to create separate configuration files that could be specified on the command line for one of my programs (instead of just default assuming it would be "app.config") so I used this simple class - which saves itself to an XML file.
http://www.dot-dash-dot.com/files/UIsettings.vb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With