KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there any way to load settings from a different file other than the default App.config file at runtime? I'd like to do this after the default config file is loaded. I use the Settings.Settings GUI in Visual Studio to create my App.config file for me. The config file ends up looking like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="SnipetTester.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </sectionGroup> </configSections> <applicationSettings> <SnipetTester.Properties.Settings> <setting name="SettingSomething" serializeAs="String"> <value>1234</value> </setting> </SnipetTester.Properties.Settings> </applicationSettings> </configuration> In code, I'm able to access the settings like this: Console.WriteLine("Default setting value: " + Properties.Settings.Default.SettingSomething); The idea is that when the application is run, I should be able to specify a config file at run time and have the application load the config file into the Properties.Settings.Default object instead of using the default app.config file. The formats of the config files would be the same, but the values of the settings would be different. I know of a way to do this with the ConfigurationManager.OpenExeConfiguration(configFile); . However, in the tests that I've run, it doesn't update
Tags (comma-separated)
Save Edits
Cancel