Hello,
I have a simple C# window app. The problem is that I want to transfer the app.config file to a secured folder so that no other users can edit it. With this, I would like to inquire if it is possible to have the app.config file stored separately with the executable file. If yes, perhaps can you please provide me some sample codes on how to achieve that.
Thanks!
Loading
Barry BritanicoPosted May 28, 2010, 10:25 AM
<SAMPLE>
<add key="Sample1" value="Barry"/>
<add key="Sample2" value="table1"/>
SAMPLE>
Would you know how can I access the keys in the SAMPLE section?
config.Sections does not have a method to acquire these data unlike the config.AppSettings.Settings.
PJ MartinsPosted May 26, 2010, 6:19 PM
Example:
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = @"c:\temp\app.config"; // Location to your configuration file
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
MessageBox.Show(config.AppSettings.Settings["MyKey"].Value);