ConfigurationManager.GetSection Method
Assembly: System.Configuration (in system.configuration.dll)
Parameters
- sectionName
The configuration section path and name.
Return Value
The specified ConfigurationSection object, or a null reference (Nothing in Visual Basic) if the section does not exist.For client applications, this method retrieves a configuration file obtained by merging the application configuration file, the local user configuration file, and the roaming configuration file.
The GetSection method accesses run-time configuration information that it cannot change. To change the configuration, you use the GetSection method on the configuration file you obtain by using one of the following Open methods:
-
OpenMappedExeConfiguration
The following code example shows how to use the GetSection method to create a configuration custom section and save it to the application configuration file.
// Get the a custom section. Show how to use the // GetSection method. static void GetCustomSection() { // Get the custom section. CustomSection custSection = ConfigurationManager.GetSection("CustomSection") as CustomSection; // Read the custom section. Console.WriteLine("File name: {0 MaxIdleTime: {1 MaxUsers: {2", custSection.FileName, custSection.MaxIdleTime, custSection.MaxUsers);
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Also, there's no actual config file specified so making the example harder to understand.
- 2/22/2009
- Thomas Lee
... and perhaps a sample app.config file ?
- 5/23/2008
- Michael_Hx
- 2/22/2009
- Thomas Lee