c# - change the settings file items in .Net console application -
i tried change setting witch console application want set , use on every execution.
1)added .settings file named inputsettings.
2)added 2 items scope:user.
3)change code this:
private projapi.inputsettings settings = new inputsettings(); settings.publishenddate = datetime.now; settings.save(); it doesn't make changes in setting file, everytime run project, setting changed when trace line.
is there mistake had?
user settings stored in different file. see this question:
if want path programmatically, can using configuration management api (you need add reference system.configuration.dll). example, here how can local user.config file path:
configuration config = configurationmanager.openexeconfiguration(configurationuserlevel.peruserroamingandlocal); console.writeline("local user config path: {0}", config.filepath);
msdn documentation lists few examples on how use application , user settings.
for example how to: write user settings @ run time c#
access setting , assign new value shown in example:
properties.settings.default.mycolor = color.aliceblue;if want persist changes settings between application sessions, call save method shown in example:
properties.settings.default.save();
Comments
Post a Comment