0

对于以下内容:

<configProtectedData >
<providers>
  <clear />
  <add CertSubjectDistinguishedName="localhost" name="X509ProtectedConfigProvider" type="X509ProtectedConfig.X509ProtectedConfigProvider, X509ProtectedConfigProvider" />
</providers>
</configProtectedData>

我该如何修改:

CertSubjectDistinguishedName="localhost"

并用不同的东西代替“本地主机”?

我不知道如何阅读“configProtectedData”部分并对其进行修改。谢谢

4

1 回答 1

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);

如果有人知道更好的方法,请发布示例。谢谢

于 2013-06-14T06:24:27.470 回答