对于以下内容:
<configProtectedData >
<providers>
<clear />
<add CertSubjectDistinguishedName="localhost" name="X509ProtectedConfigProvider" type="X509ProtectedConfig.X509ProtectedConfigProvider, X509ProtectedConfigProvider" />
</providers>
</configProtectedData>
我该如何修改:
CertSubjectDistinguishedName="localhost"
并用不同的东西替换“localhost”?
我无法弄清楚如何阅读“configProtectedData”部分并修改它。 感谢
答案 0 :(得分:0)
我使用XMLDocument解决了它:
string path = Path.Combine(targetDirectory, applicationExecutableName);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);
XmlNode node = xmlDoc.SelectSingleNode("configuration/configProtectedData/providers");
node.InnerXml = string.Format("<add CertSubjectDistinguishedName=\"{0}\" CertStoreName=\"{1}\" name=\"X509ProtectedConfigProvider\" type=\"ProtectedConfigProvider.X509ProtectedConfigProvider, X509ProtectedConfigProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=098027505e2ed139\" />", certSubject, certStoreName);
xmlDoc.Save(path);
如果有人知道更好的方法,请发布样本。感谢