Skip to content

Instantly share code, notes, and snippets.

@aturgarg
Created June 27, 2011 14:29
Show Gist options
  • Select an option

  • Save aturgarg/1048962 to your computer and use it in GitHub Desktop.

Select an option

Save aturgarg/1048962 to your computer and use it in GitHub Desktop.
Get EXE config data dynamically
private static string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location.ToString();
if (!string.IsNullOrEmpty(servicePath))
{
Configuration config = ConfigurationManager.OpenExeConfiguration(exePath);
//here fetching the data from AppSettings with key name "UserName"
string userName = config.AppSettings.Settings["UserName"].Value.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment