giammin

Save config at runtime

Aug 23rd, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. //app.config
  2. var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  3. //web.config
  4. //var config = WebConfigurationManager.OpenWebConfiguration("~");
  5. var section = (NameValueConfigurationCollection) config.GetSection("thirdPartySection");
  6. section["someKey"].Value = "someValue";
  7. //check file permissions!!
  8. config.Save();
Advertisement
Add Comment
Please, Sign In to add comment