-1
我想從我的項目更新另一個應用程序的app.config文件都在C#中。我知道如何更新它在內存中的項目,但不知道如何訪問我的其他項目的app.config文件。我有以下的代碼,但會改變我的當前項目不是另一個的app.config文件....感謝您的建議或想法更新配置文件
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
foreach (XmlElement element in xmlDoc.DocumentElement)
{
if (element.Name.Equals("appSettings"))
{
foreach (XmlNode node in element.ChildNodes)
{
if (node.Attributes[0].Value.Equals("Setting1"))
{
node.Attributes[1].Value = "New Value";
}
}
}
}
我還沒有玩過這些類,但我想知道是否http://stackoverflow.com/questions/3912727/openmappedexeconfiguration-vs - 配置配置可能有任何用處。雖然不確定。 –