Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using System.Configuration;
  2. using System.Diagnostics;
  3.  
  4. namespace ConsoleApp1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  11. ConfigurationSection section = configuration.GetSection("connectionStrings");
  12.  
  13. if (!section.SectionInformation.IsProtected && !section.ElementInformation.IsLocked)
  14. {
  15. section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
  16. section.SectionInformation.ForceSave = true;
  17. section.CurrentConfiguration.Save(ConfigurationSaveMode.Full);
  18. }
  19.  
  20. Debug.Assert(section.SectionInformation.IsProtected);
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement