How to read and write app. config
Using System;
Using System. Collections. Generic;
Using System. text;
Using System. configuration;
Using System. collections;
Namespace Servicesconfiguration
{
Public Class Configurationdispose
{
Public Configurationdispose ()
{
}
# Region Getconfiguration
/// <Summary>
/// Obtain the value in the deletemetadata.
/// </Summary>
/// <Param name = "key"> Key </Param>
/// <Returns> Value </Returns>
Public Static String Getconfiguration ( String Key)
{
ReturnConfigurationmanager. deleetask[ key];
}
# Endregion
# Region Getconfigurationlist
/// <Summary>
/// Obtains the Value List in the deleteworker.
/// </Summary>
/// <Param name = "filepath"> Configuration File Path </Param>
/// <Returns> Value List </Returns>
Public Static Keyvalueconfigurationcollection getconfigurationlist ( String Filepath)
{
Appsettingssection appsection = Null ; // Appsection object
Configuration = Null ; // Configuration object
Keyvalueconfigurationcollection K = Null ; // Type of the key-Value Pair returned
Configuration = Configurationmanager. openexeconfiguration (filepath );
// Get the ettings Section
Appsection = (Appsettingssection) configuration. Sections [ " Appsettings " ];
// Obtain the key-value pairs of the deleetting Section
K = Appsection. settings;
Return K;
}
# Endregion