How to get values from app settings section

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 691
Suppose we have

<appSettings>      
<add key="RuleMaster" value="DataSource\RuleMaster.xml"/>
</appSettings>


To get the value from "RuleMaster", let us write the below code

 public string GetSettingValue(string configKey)
{
try
{
return System.Configuration.ConfigurationManager.AppSettings[configKey].ToString();
}
catch (Exception ex)
{
return string.Empty;
}
}

Use it : GetSettingValue("RuleMaster");

Comments or Responses

Login to post response