Change existing XML tag attributes in project resource



I have an XML file in my C# project resource and I want to change some attributes programmatically. I can load the XML from resource and change the attribute value using this code:



var res = Assembly.GetAssembly(typeof(Global.Configuration))
.GetManifestResourceStream("MyNamespace.Resources.Configuration.xml");

var xReader = new XmlTextReader(res);
XDocument loadedXml = XDocument.Load(xReader);
loadedXml.XPathSelectElement("//configuration//setting/autosave")
.Attribute("onoff").Value = chkAutoSave.Checked.ToString();


But how can I save the changes in my XML?


No comments:

Post a Comment