Read/Write App.Config File with .NET 2.0 4 January 2008
Posted by Ahmed Abdul Moniem in Windows Application Development.trackback
Introduction
Author: Alois Kraus and the full article from here
This is my first CodeProject article. I would like to show you the most important changes in the System.Configuration namespace with .NET 2.0. I have looked at my blog referrer statistics and saw about 20 hits/day by Google. Most of them were searching information on how to configure the new Enterprise Library but there are also a significant number of people that seem to seek answers to the following questions:
- How to read/write to App.Config?
- How to store a list of objects in a config file via the
System.Configurationmechanism?
Reason enough for me to shed more light on the System.Configuration namespace. The main changes from .NET 1.0/1.1 in the System.Configuration namespace are:
- Write to your App.Config file through the Configuration class
- New configuration model for Windows Forms applications
- Store complex objects including object collections in your
App.ConfigFile - It is possible to store Connection Strings in the App.Config file. See ConnectionSettings which enables you to store your settings on an SQL Server. The Enterprise Library for Sample
SqlConfigurationexercises this by implementing aSqlConfigurationSourcewhich can store and retrieve a ConfigurationSection
So where to start? I think first I will show you the config file and explain how you can create it programmatically in your application.
Comments»
No comments yet — be the first.