After reading the answers here and playing with the ConfigurationManager.Open methods, I got the following:
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MyApp", "MyApp.config"); Configuration MyAppConfig = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = path }, ConfigurationUserLevel.None);
The good part is a file that should not exist, and if you name Save() on it, it will create a folder and a file for you. AppSettings["key"] did not work, so I had to use
MyAppConfig.AppSettings.Settings["key"].Value
to read and write the existing value and
MyAppConfig.AppSettings.Settings.Add("key", value)
to add a new value.
Alexdev
source share