




























public void ProtectSection(string sectionName)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSection protectedSection= config.GetSection(sectionName);
// Encrypts when possible
if ((protectedSection!=null) && (!protectedSection.IsReadOnly()) && (! protectedSection.SectionInformation.IsProtected)
&& (!protectedSection.SectionInformation.IsLocked) && (protectedSection.SectionInformation.IsDeclared))
{
// Protect (encrypt)the section.
protectedSection.SectionInformation.ProtectSection(null);
// ' Save the encrypted section.
protectedSection.SectionInformation.ForceSave =true;
config.Save(ConfigurationSaveMode.Full);
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。