ASP.Net - How do I programatically edit external config files at runtime
<p>By external config files, I mean .config files other than web.config. I've seen all the examples on how to edit web.config at runtime, but I want to edit a config file referenced by a configSource for appSettings. I want to modify only the external file and I will handle the app recycle.</p>

<p>Ideally I would like to use a built-in class to deal with the edits, but if the only option is a manual File open/parse, etc, then sobeit.</p>

<p>The general idea behind all this being a Settings page that is viewed at app startup, user sets their particulars and then saves the changes, then the real app starts up. quick and easy install app/configure page, so I'd like to leverage .config if at all possible.</p>

<p>Thanks!</p>

<p>FOLLOWUP - Quick Snippet to use XmlDocument to change an appSetting key value:</p>

<pre><code>string path = Server.MapPath("~/my.config");

XmlDocument doc = new XmlDocument();
doc.Load(path);

XmlNode node = doc.SelectSingleNode("/appSettings/add[@key='myKey']");
node.Attributes[1].Value = "myVal";

XmlTextWriter writer = new XmlTextWriter(path, null);
writer.Formatting = Formatting.Indented;
doc.WriteTo(writer);
writer.Flush();
writer.Close();
</code></pre>
