Config file will look like –
<appSettings>
<add key=”Applications” value=”Proj1|Proj2|App1|App2|App3″/>
</appSettings>
C# code will like this –
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
AppSettingsSection configSection = config.AppSettings;
try
{
if (configSection != null)
{
if (configSection.IsReadOnly() == false && configSection.SectionInformation.IsLocked == false)
{
configSection.Settings[“KEY”].Value += “|NewValue”;
ConfigurationManager.RefreshSection(“appSettings”);
config.Save(ConfigurationSaveMode.Modified);
}
}
}
catch (ConfigurationException ex)
{
MessageBox.Show(ex.Message, “Configuration Error”, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Leave a reply to Haddy58 Cancel reply