My.Settings.YourSettingName is a read only property for application scope configuration
By design you can’t modify application scope configuration settings, e.g. My.Settings.Setting1 is always read-only.
You can change the scope of the setting from Application to User, but then the setting will be stored in user.config instead of app.config
Another solution is to access application configuration file directly via System.Configuration.Configuration class. Here a small sample that updates LastDownloadDate configuration setting inside applicationSettings/APP.My.MySettings section:
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim sec As ClientSettingsSection = config.GetSection("applicationSettings/APP.My.MySettings")
sec.Settings.Get("LastDownloadDate").Value.ValueXml.InnerXml = Now.ToString
sec.SectionInformation.ForceSave = True
One thought on “How to Modify applicationSettings section”
That is a great idea. Often I find myself wneinrdog why something’s doing something I don’t expect and it’s only an hour later when I realise it has been configured at a bizarre scope! (Quite often by myself and I’d just forgotten! ).