I can read .config files all day, but for some reason I cant write to them..
After searching for a few days, there are some that have code showing to
write, but none of them seem to work. Someone explain to me what could be
the problem?
I'm admin of the machine, I'm writting local, and this is the code I've
tried..
Way #1
--------------
Configuration config;
config =
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
config.AppSetti ngs.Settings[strKey].Value = strValue; //error, Object
reference not set to an instance of an object
config.Save(Con figurationSaveM ode.Modified);
ConfigurationMa nager.RefreshSe ction("appSetti ngs");
Way #2
--------------
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
ConfigurationMa nager.AppSettin gs.Add(strKey, strValue); //error,
config is readonly.. But it's not..
ConfigurationMa nager.RefreshSe ction("appSetti ngs");
After searching for a few days, there are some that have code showing to
write, but none of them seem to work. Someone explain to me what could be
the problem?
I'm admin of the machine, I'm writting local, and this is the code I've
tried..
Way #1
--------------
Configuration config;
config =
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
config.AppSetti ngs.Settings[strKey].Value = strValue; //error, Object
reference not set to an instance of an object
config.Save(Con figurationSaveM ode.Modified);
ConfigurationMa nager.RefreshSe ction("appSetti ngs");
Way #2
--------------
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
ConfigurationMa nager.AppSettin gs.Add(strKey, strValue); //error,
config is readonly.. But it's not..
ConfigurationMa nager.RefreshSe ction("appSetti ngs");