开发者

How update xml file settings

I have my own xml settings file in winform app. It is installed on some location. And I need to update this file (add some new atributes/settings) without loosing old settings.

Example old xml setting:

<settings>
  <someSetting>Old Value</someSetting>
<settings>

Example new xml setting file:

 <settings>
   <someSetting>default value</someSettingNew>
   <someSettingNew>defaul value</someSettingNew>
 <settings>

I need new xml setting file look after update like this:

 <settings>
   <someSetting>Old Value</someSettingNew>
   <someSettingNew>defaul value</someSettingNew>
 <settings>

How can I do this in C# .NET Framework 3.5. And I know that I can do this with App.config, but I need my own manager. I need to share this config file between two apps (Settings App for Windows Service and that Windows Service)

Thanx.

UPDATE: I have to explain my workflow:

  1. windows service + app gui is instaled with instalator
  2. windows service is configured with app gui
  3. i will create update (dll + new xml config file)
  4. dll's are deployed, and i need to merge old xml config file with new config file (new parameters and default value). How do this programmicaly? I want update only xml file, not program code. In windows servic app I can detect update so I can call some proced开发者_开发技巧ure to load new settings. Thats what I need, how do this procedure?


You could use XDocument:

var doc = XDocument.Load("test.xml");
doc.Root.Add(new XElement("someSettingNew", "defaul value"));
doc.Save("test.xml");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜