c# - Unable to create config file with AppSettings section in local user directory -
i'm able read .config file , write changes when config file located in application directory. want change because of user permissions , move .config file users/xxx/local directory. i've learned need change sectioninformation.allowexedefinition property configurationallowexedefinition.machinetolocaluser i'm unable change property appsettings section.
this how read appsettings
//read com port settings uimodel_settings.comport = system.configuration.configurationmanager.appsettings.get("comport");
this how write appsettings
system.configuration.configuration config = configurationmanager.openexeconfiguration(configurationuserlevel.peruserroamingandlocal); config.appsettings.settings["comport"].value = uimodel_settings.comport; config.save(configurationsavemode.modified); configurationmanager.refreshsection("appsettings");
when run locked error @ save method: configurationsection properties cannot edited when locked.
any ideas how fix this? or how can create file under local users directory?
thanks
zjerre
in project, have settings file item (e.g. settings.settings)?
if generate settings class static default property can use access appsettings elements. if not try adding 1 solution explorer -> project -> add item -> settings file.
uimodel_settings.comport = settings.default.comport;
Comments
Post a Comment