private void Save(CLogLineMatch match) { if (!_dirty) { return; } if (_readOnlyMode) { throw new CLogEnterReadOnlyModeException("WontWriteWhileInReadonlyMode:ETWManifest", CLogHandledException.ExceptionType.WontWriteInReadOnlyMode, match); } // // Devs prefer XML that is readable in their editor - make an attempt to format their XML in a way that diffs okay // StringBuilder stringBuilder = new StringBuilder(); System.Xml.Linq.XElement element = System.Xml.Linq.XElement.Parse(doc.InnerXml); XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; settings.Indent = true; settings.NewLineOnAttributes = true; using (var xmlWriter = XmlWriter.Create(stringBuilder, settings)) { element.Save(xmlWriter); } File.WriteAllText(xmlFileName, stringBuilder.ToString()); _dirty = false; }
public static void SaveSafe(this System.Xml.Linq.XElement element, string path) { if (!Validation.CanWrite(path, false)) { DebugConsole.ThrowError($"Cannot save XML element to \"{path}\": modifying the files in this folder/with this extension is not allowed."); return; } element.Save(path); }
public static void SaveSafe(this System.Xml.Linq.XElement element, string path) { if (!Validation.CanWrite(path)) { DebugConsole.ThrowError($"Cannot save XML element to \"{path}\": failed validation"); return; } element.Save(path); }
protected void SaveOptionsFile(System.Xml.Linq.XElement rootElem) { if (this.Package == null) { return; } string path = System.IO.Path.Combine(this.Package.UserLocalDataPath, OPTIONS_FILE_NAME); rootElem.Save(path); }
private void WriteToXml() { List <System.Xml.Linq.XElement> intNodeList = new List <System.Xml.Linq.XElement>(); foreach (var link in fileList) { intNodeList.Add(new System.Xml.Linq.XElement("imageLink", link)); } System.Xml.Linq.XElement externalNode = new System.Xml.Linq.XElement("libraryImages", intNodeList); externalNode.Save("XmlData.xml"); }
private void BtnNext_Clicked(object sender, EventArgs e) { var backingFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Config.xml"); System.Xml.Linq.XElement xEleList = System.Xml.Linq.XElement.Load(backingFile); if (swtchDoNotShowAgain.IsToggled) { xEleList.Descendants("DoNotShowAgain").First().Value = "true"; xEleList.Save(backingFile); } Application.Current.MainPage = new NavigationPage(new MainSearchWindow()); }
public void saveSetting(string xmlFilename = null) { var xe = new System.Xml.Linq.XElement(settingXmlName); foreach (var k in settingData.Keys) { xe.Add(new System.Xml.Linq.XElement(k, settingData[k])); } var xmlPath = getXmlPath(xmlFilename); xe.Save(xmlPath); }
/// <summary> /// Carrega a definição para o relatório. /// </summary> /// <param name="localReport">Relatório local para onde a definição será carregada.</param> /// <param name="report"></param> protected virtual void LoadDefinition(Microsoft.Reporting.WebForms.LocalReport localReport, System.IO.Stream report) { _compatiblesParameters.Clear(); if (Document is IReportDefinitionContainer) { System.Xml.Linq.XElement root = null; root = System.Xml.Linq.XElement.Load(report, System.Xml.Linq.LoadOptions.None); var nameAttribute = root.Attribute("Name"); if (nameAttribute != null && !string.IsNullOrEmpty(nameAttribute.Value) && Document.Title == null) { Document.Title = nameAttribute.Value.GetFormatter(); } var reportDefinition = root.GetDefaultNamespace().NamespaceName; var reportParameters = root.Elements(System.Xml.Linq.XName.Get("ReportParameters", reportDefinition)).FirstOrDefault(); var parameters = new List <string>(); if (reportParameters != null) { foreach (var parameter in reportParameters.Elements(System.Xml.Linq.XName.Get("ReportParameter", reportDefinition))) { var paramenterName = parameter.Attribute("Name"); if (paramenterName != null) { parameters.Add(paramenterName.Value); } } } _compatiblesParameters = parameters; using (var stream = new System.IO.MemoryStream()) { root.Save(stream); stream.Seek(0, System.IO.SeekOrigin.Begin); localReport.LoadReportDefinition(stream); } } else { localReport.LoadReportDefinition(report); } }
private void B_Load_Click(object sender, EventArgs e) { //Read Import file for all currently specified Container Names _containerNames = lootContainernames.getNames(); XmlDocument doc = new XmlDocument(); doc.Load(T_XMLFile.Text); XmlNodeList ProbTmpl = doc.GetElementsByTagName("loot"); readProbTemplates(ProbTmpl); XmlNodeList itemRefList = doc.GetElementsByTagName("item"); //manually add the "Empty" Loot Group since it is missed in the Search for "item" lootGroup emptyLG = new lootGroup(); lootGroupContents emptyLGContents = new lootGroupContents(); emptyLGContents.count = 1; emptyLGContents.item = "nothing"; emptyLGContents.prob = 1; emptyLG.count = 1; emptyLG.lgTotProb = 1; emptyLG.contents.Add(emptyLGContents); _lootGroups.Add("empty", emptyLG); foreach (XmlElement lg in itemRefList) { //Parse through each item value in the loot.xml, Since Item will be Name or Group. //Get the value of the parent element to get the Lootgroup name or loot container id //For each loot group, parse out each and every item, so in the end we have a Loot container with all possible items, no groups listed //First, check the Parent Element string parentNode = lg.ParentNode.Name; if(parentNode=="lootgroup") { //Lootgroup, process as a lootgroup string lootgroupName = lg.ParentNode.Attributes["name"].Value; if(!_lootGroups.ContainsKey(lootgroupName)) { //Lootgroup doesn't exist, add it M_Output.AppendText("This is a Loot Group: " + lootgroupName + Environment.NewLine); lootGroup tempGroup = new lootGroup(); //Parse the Count Value of the lootgroup string lgcount; try { lgcount = lg.ParentNode.Attributes["count"].Value; } catch { //Null Ref, no Count value for this Parent node specified, only 1 of the items is selected, assume count = 1 lgcount = "1"; } countParse tempValueLG = new countParse(); if(parseCount(lgcount, tempValueLG)) { tempGroup.count = tempValueLG.count; tempGroup.minCount = tempValueLG.minCount; tempGroup.maxCount = tempValueLG.maxCount; tempGroup.minmax = tempValueLG.minmax; tempGroup.incAll = tempValueLG.incAll; } else { //Failed to parse the Count properly M_Output.AppendText("Failed to parse Count=" + lgcount + "Into its values properly for lootgroup(" + lootgroupName + Environment.NewLine); } _lootGroups.Add(lootgroupName, tempGroup); } //lootgroup already exists/now exists, check to see if this is a group or item //Element is an Item, add it to the LG //Parse the Count Parameter if there is one: lootGroupContents tempLGContents = new lootGroupContents(); countParse tempValue = new countParse(); string count = lg.GetAttribute("count"); string prob = lg.GetAttribute("prob"); string probTmpl = lg.GetAttribute("loot_prob_template"); if (parseCount(count, tempValue))//Parse Count into its fields, if it fails, assume Count=1 by leaving it default. { tempLGContents.count = tempValue.count; tempLGContents.minCount = tempValue.minCount; tempLGContents.maxCount = tempValue.maxCount; tempLGContents.minmax = tempValue.minmax; } //Try to parse Prob to a Decimal, if it fails assume it is a 1 by leaving it default. decimal decValue; if (probTmpl != "") { //This is a Probability Template, not a Straight Probability, find the matching Probability Template and pull the Probability form there foreach (KeyValuePair<int, Decimal> kv in _LootProbTmpl[probTmpl]) { if (Int32.Parse(T_Player.Text) < kv.Key) { tempLGContents.prob = kv.Value; break; } } M_Output.AppendText(""); } else { if (Decimal.TryParse(prob, out decValue)) { tempLGContents.prob = decValue; } } string name=""; if (lg.GetAttribute("name") != "") { //Element is an Item, use Item Name name = lg.GetAttribute("name"); tempLGContents.item = name; tempLGContents.isGroup = false; } else if (lg.GetAttribute("group") != "") { //Element is a Group, Add it to the Contents of the current lootgroup //Check to see if this group already exists in the Dictionary, if not error name = lg.GetAttribute("group"); tempLGContents.item = name; tempLGContents.isGroup = true; } else { //Element is unknown M_Output.AppendText("Unknown Element" + Environment.NewLine); } _lootGroups[lootgroupName].contents.Add(tempLGContents); _lootGroups[lootgroupName].lgTotProb += tempLGContents.prob; M_Output.AppendText(name + ", " + count + ", " + prob + Environment.NewLine); } else if(parentNode=="lootcontainer") { //Loot Container, parse loot items out and figure Probabilities //First parse all parts of the Loot Container itself //Check to see if the Container has already been saved int containerID = Int32.Parse(lg.ParentNode.Attributes["id"].Value); if (!_lootContainer.ContainsKey(containerID)) { //LootContainer doesn't exist, add it M_Output.AppendText("This is a Loot Container: " + containerID + Environment.NewLine); lootContainer tempContainer = new lootContainer(); //Attempt to lookup the Name of this Container ID, and add it if it exists if (!_containerNames.TryGetValue(containerID, out tempContainer.name)) { //Container failed to get a name, add the Container ID to the _ContainerNames, with no name _containerNames.Add(containerID, ""); } //Parse the Count Value of the lootgroup tempContainer.size = lg.ParentNode.Attributes["size"].Value; ; countParse tempValueLC = new countParse(); string countLC = lg.ParentNode.Attributes["count"].Value; if (parseCount(countLC, tempValueLC))//Parse Count into its fields, if it fails, assume Count=1 by leaving it default. { tempContainer.count = tempValueLC.count; tempContainer.minCount = tempValueLC.minCount; tempContainer.maxCount = tempValueLC.maxCount; tempContainer.minmax = tempValueLC.minmax; } else { //Failed to parse the Count properly M_Output.AppendText("Failed to parse Count=" + countLC + "Into its values properly for lootContainer: " + containerID + Environment.NewLine); } _lootContainer.Add(containerID, tempContainer); } //Container exists/now exists, parse this Item/Group into the List //Parse Count value if there is one lootGroupContents tempLGContents = new lootGroupContents(); countParse tempValue = new countParse(); string count = lg.GetAttribute("count"); string prob = lg.GetAttribute("prob"); string probTmpl = lg.GetAttribute("loot_prob_template"); if (parseCount(count, tempValue))//Parse Count into its fields, if it fails, assume Count=1 by leaving it default. { tempLGContents.count = tempValue.count; tempLGContents.minCount = tempValue.minCount; tempLGContents.maxCount = tempValue.maxCount; tempLGContents.minmax = tempValue.minmax; } //Try to parse Prob to a Decimal, if it fails assume it is a 1 by leaving it default. decimal decValue; if (probTmpl != "") { //This is a Probability Template, not a Straight Probability, find the matching Probability Template and pull the Probability form there foreach (KeyValuePair<int, Decimal> kv in _LootProbTmpl[probTmpl]) { if (Int32.Parse(T_Player.Text) < kv.Key) { tempLGContents.prob = kv.Value; tempLGContents.tempProbMod = kv.Value; break; } } M_Output.AppendText(""); } else { if (Decimal.TryParse(prob, out decValue)) { tempLGContents.prob = decValue; tempLGContents.tempProbMod = decValue; } } //Determine if this is an Item, or a Group string name = ""; if (lg.GetAttribute("name") != "") { //Element is an Item, use Item Name name = lg.GetAttribute("name"); tempLGContents.item = name; tempLGContents.isGroup = false; _lootContainer[containerID].contents.Add(tempLGContents); } else if (lg.GetAttribute("group") != "") { //Element is a Group, For Containers, we want to parse the Group out to individual Items. name = lg.GetAttribute("group"); //Parse through the Group for its Items List<lootGroupContents> explodedContents = new List<lootGroupContents>(); explodedContents = explodeGroup(ref name, ref tempLGContents); _lootContainer[containerID].contents.AddRange(explodedContents); } else { //Element is unknown M_Output.AppendText("Unknown Element" + Environment.NewLine); } } } //Save All Found Container Names back to the XML File to allow user to edit it and add names for next run. System.Xml.Linq.XElement el = new System.Xml.Linq.XElement("root", _containerNames.Select(kv => new System.Xml.Linq.XElement("ID" + kv.Key.ToString(), kv.Value))); string fileName = "containernames.xml"; el.Save(fileName); M_Output.Clear(); //Equate Container's Total Probability: foreach (KeyValuePair<int,lootContainer> lc in _lootContainer) { M_Output.AppendText("Loot Container: " + lc.Key + Environment.NewLine); M_Output.AppendText(Environment.NewLine); decimal tempProb = 0; //Added to break code for testing specific Containers if (lc.Key == 5) { M_Output.AppendText(""); } foreach (lootGroupContents lGC in lc.Value.contents) { tempProb += lGC.tempProbMod; } decimal containerTotProb = tempProb; List <lootGroupContents> SortedList = lc.Value.contents.OrderBy(o => o.item).ToList(); foreach (lootGroupContents item in SortedList) { item.prob = item.tempProbMod / containerTotProb; item.tempProbMod = 0; //M_Output.AppendText(" " + item.item + ", " + Math.Round(item.tempProbMod,3) + ", " + Math.Round(item.tempProbMod/containerTotProb, 3) + Environment.NewLine); //Add to the list of Item Names if not already in it. if(!_itemNames.Contains(item.item)) { _itemNames.Add(item.item); } } } V_LContainer.DataSource = new BindingSource(getContainerBinding(_lootContainer), null); V_LContainer.DisplayMember = "Value"; V_LContainer.ValueMember = "Key"; V_LContainer.Refresh(); V_LContainer.Enabled = true; _itemNames.Sort(); //Parse through the Containers and add Containers Witohut names to import file. }
private void B_Load_Click(object sender, EventArgs e) { M_Output.Clear(); V_LContainer.DataSource = null; _lootGroups.Clear(); _lootContainer.Clear(); _LootProbTmpl.Clear(); //Read Import file for all currently specified Container Names _containerNames = lootContainernames.getNames(); XmlDocument doc = new XmlDocument(); doc.Load(T_XMLFile.Text); XmlNodeList ProbTmpl = doc.GetElementsByTagName("loot"); readProbTemplates(ProbTmpl); XmlNodeList itemRefList = doc.GetElementsByTagName("item"); //manually add the "Empty" Loot Group since it is missed in the Search for "item" lootGroup emptyLG = new lootGroup(); lootGroupContents emptyLGContents = new lootGroupContents(); emptyLGContents.count = 1; emptyLGContents.item = "nothing"; emptyLGContents.prob = 1; emptyLG.count = 1; emptyLG.lgTotProb = 1; emptyLG.contents.Add(emptyLGContents); _lootGroups.Add("empty", emptyLG); foreach (XmlElement lg in itemRefList) { //Parse through each item value in the loot.xml, Since Item will be Name or Group. //Get the value of the parent element to get the Lootgroup name or loot container id //For each loot group, parse out each and every item, so in the end we have a Loot container with all possible items, no groups listed //First, check the Parent Element string parentNode = lg.ParentNode.Name; if (parentNode == "lootgroup") { //Lootgroup, process as a lootgroup string lootgroupName = lg.ParentNode.Attributes["name"].Value; if (!_lootGroups.ContainsKey(lootgroupName)) { //Lootgroup doesn't exist, add it M_Output.AppendText("This is a Loot Group: " + lootgroupName + Environment.NewLine); lootGroup tempGroup = new lootGroup(); //Parse the Count Value of the lootgroup string lgcount; try { lgcount = lg.ParentNode.Attributes["count"].Value; } catch { //Null Ref, no Count value for this Parent node specified, only 1 of the items is selected, assume count = 1 lgcount = "1"; } countParse tempValueLG = new countParse(); if (parseCount(lgcount, tempValueLG)) { tempGroup.count = tempValueLG.count; tempGroup.minCount = tempValueLG.minCount; tempGroup.maxCount = tempValueLG.maxCount; tempGroup.minmax = tempValueLG.minmax; tempGroup.incAll = tempValueLG.incAll; } else { //Failed to parse the Count properly M_Output.AppendText("Failed to parse Count=" + lgcount + "Into its values properly for lootgroup(" + lootgroupName + Environment.NewLine); } _lootGroups.Add(lootgroupName, tempGroup); } //lootgroup already exists/now exists, check to see if this is a group or item //Element is an Item, add it to the LG //Parse the Count Parameter if there is one: lootGroupContents tempLGContents = new lootGroupContents(); countParse tempValue = new countParse(); string count = lg.GetAttribute("count"); string prob = lg.GetAttribute("prob"); string probTmpl = lg.GetAttribute("loot_prob_template"); if (parseCount(count, tempValue))//Parse Count into its fields, if it fails, assume Count=1 by leaving it default. { tempLGContents.count = tempValue.count; tempLGContents.minCount = tempValue.minCount; tempLGContents.maxCount = tempValue.maxCount; tempLGContents.minmax = tempValue.minmax; } //Try to parse Prob to a Decimal, if it fails assume it is a 1 by leaving it default. if (!_LootProbTmpl.ContainsKey(probTmpl) && probTmpl != "") { // MessageBox.Show("Missing Probability: " + probTmpl); } decimal decValue; if (probTmpl != "" && _LootProbTmpl.ContainsKey(probTmpl)) { //This is a Probability Template, not a Straight Probability, find the matching Probability Template and pull the Probability form there foreach (KeyValuePair <int, Decimal> kv in _LootProbTmpl[probTmpl]) { if (Int32.Parse(T_Player.Text) < kv.Key) { tempLGContents.prob = kv.Value; break; } } M_Output.AppendText(""); } else { if (Decimal.TryParse(prob, out decValue)) { tempLGContents.prob = decValue; } } string name = ""; if (lg.GetAttribute("name") != "") { //Element is an Item, use Item Name name = lg.GetAttribute("name"); tempLGContents.item = name; tempLGContents.isGroup = false; } else if (lg.GetAttribute("group") != "") { //Element is a Group, Add it to the Contents of the current lootgroup //Check to see if this group already exists in the Dictionary, if not error name = lg.GetAttribute("group"); tempLGContents.item = name; tempLGContents.isGroup = true; } else { //Element is unknown M_Output.AppendText("Unknown Element" + Environment.NewLine); } _lootGroups[lootgroupName].contents.Add(tempLGContents); _lootGroups[lootgroupName].lgTotProb += tempLGContents.prob; M_Output.AppendText(name + ", " + count + ", " + prob + Environment.NewLine); } else if (parentNode == "lootcontainer") { //Loot Container, parse loot items out and figure Probabilities //First parse all parts of the Loot Container itself //Check to see if the Container has already been saved int containerID = Int32.Parse(lg.ParentNode.Attributes["id"].Value); if (!_lootContainer.ContainsKey(containerID)) { this.V_LContainer.Items.Add(" Loot Container: " + containerID); //LootContainer doesn't exist, add it M_Output.AppendText("This is a Loot Container: " + containerID + Environment.NewLine); lootContainer tempContainer = new lootContainer(); //Attempt to lookup the Name of this Container ID, and add it if it exists if (!_containerNames.TryGetValue(containerID, out tempContainer.name)) { //Container failed to get a name, add the Container ID to the _ContainerNames, with no name _containerNames.Add(containerID, ""); } //Parse the Count Value of the lootgroup tempContainer.size = lg.ParentNode.Attributes["size"].Value;; countParse tempValueLC = new countParse(); string countLC = "1"; if (lg.ParentNode.Attributes["count"] != null) { countLC = lg.ParentNode.Attributes["count"].Value; } if (parseCount(countLC, tempValueLC))//Parse Count into its fields, if it fails, assume Count=1 by leaving it default. { tempContainer.count = tempValueLC.count; tempContainer.minCount = tempValueLC.minCount; tempContainer.maxCount = tempValueLC.maxCount; tempContainer.minmax = tempValueLC.minmax; } else { //Failed to parse the Count properly M_Output.AppendText("Failed to parse Count=" + countLC + "Into its values properly for lootContainer: " + containerID + Environment.NewLine); } _lootContainer.Add(containerID, tempContainer); } //Container exists/now exists, parse this Item/Group into the List //Parse Count value if there is one lootGroupContents tempLGContents = new lootGroupContents(); countParse tempValue = new countParse(); string count = lg.GetAttribute("count"); string prob = lg.GetAttribute("prob"); string probTmpl = lg.GetAttribute("loot_prob_template"); if (parseCount(count, tempValue))//Parse Count into its fields, if it fails, assume Count=1 by leaving it default. { tempLGContents.count = tempValue.count; tempLGContents.minCount = tempValue.minCount; tempLGContents.maxCount = tempValue.maxCount; tempLGContents.minmax = tempValue.minmax; } //Try to parse Prob to a Decimal, if it fails assume it is a 1 by leaving it default. decimal decValue; if (probTmpl != "") { //This is a Probability Template, not a Straight Probability, find the matching Probability Template and pull the Probability form there foreach (KeyValuePair <int, Decimal> kv in _LootProbTmpl[probTmpl]) { if (Int32.Parse(T_Player.Text) < kv.Key) { tempLGContents.prob = kv.Value; tempLGContents.tempProbMod = kv.Value; break; } } M_Output.AppendText(""); } else { if (Decimal.TryParse(prob, out decValue)) { tempLGContents.prob = decValue; tempLGContents.tempProbMod = decValue; } } //Determine if this is an Item, or a Group string name = ""; if (lg.GetAttribute("name") != "") { //Element is an Item, use Item Name name = lg.GetAttribute("name"); tempLGContents.item = name; tempLGContents.isGroup = false; _lootContainer[containerID].contents.Add(tempLGContents); } else if (lg.GetAttribute("group") != "") { //Element is a Group, For Containers, we want to parse the Group out to individual Items. name = lg.GetAttribute("group"); //Parse through the Group for its Items List <lootGroupContents> explodedContents = new List <lootGroupContents>(); explodedContents = explodeGroup(ref name, ref tempLGContents); _lootContainer[containerID].contents.AddRange(explodedContents); } else { //Element is unknown M_Output.AppendText("Unknown Element" + Environment.NewLine); } } } //Save All Found Container Names back to the XML File to allow user to edit it and add names for next run. System.Xml.Linq.XElement el = new System.Xml.Linq.XElement("root", _containerNames.Select(kv => new System.Xml.Linq.XElement("ID" + kv.Key.ToString(), kv.Value))); string fileName = "containernames.xml"; el.Save(fileName); M_Output.Clear(); //Equate Container's Total Probability: foreach (KeyValuePair <int, lootContainer> lc in _lootContainer) { M_Output.AppendText("Loot Container: " + lc.Key + Environment.NewLine); M_Output.AppendText(Environment.NewLine); decimal tempProb = 0; //Added to break code for testing specific Containers if (lc.Key == 5) { M_Output.AppendText(""); } foreach (lootGroupContents lGC in lc.Value.contents) { tempProb += lGC.tempProbMod; } decimal containerTotProb = tempProb; List <lootGroupContents> SortedList = lc.Value.contents.OrderBy(o => o.item).ToList(); foreach (lootGroupContents item in SortedList) { if (containerTotProb == 0) { containerTotProb = 1; } item.prob = item.tempProbMod / containerTotProb; item.tempProbMod = 0; //M_Output.AppendText(" " + item.item + ", " + Math.Round(item.tempProbMod,3) + ", " + Math.Round(item.tempProbMod/containerTotProb, 3) + Environment.NewLine); //Add to the list of Item Names if not already in it. if (!_itemNames.Contains(item.item)) { _itemNames.Add(item.item); } } } V_LContainer.DataSource = new BindingSource(getContainerBinding(_lootContainer), null); V_LContainer.DisplayMember = "Value"; V_LContainer.ValueMember = "Key"; V_LContainer.Refresh(); V_LContainer.Enabled = true; _itemNames.Sort(); //Parse through the Containers and add Containers Witohut names to import file. }
private void WritePluginOptions() { System.Xml.Linq.XElement settingsElement = new System.Xml.Linq.XElement("Settings"); foreach (Plugins.INotifier plugin in plugins) { /* example of settings file that would store the selected options so they can be reloaded the next time the application loads * <Settings> * <Setting Application="Twitter"> * <Option Id="1" Active="true"><Numerics><Numeric>20</Numeric></Numerics></Option> * <Option Id="3" Active="false"><Gestures><Gesture>1</Gesture></Gestures></Option> * </Setting> * </Settings> */ SavePluginOptions(plugin.NotificationApplication, pluginOptions[plugin.NotificationApplication], settingsElement); } settingsElement.Save(System.Windows.Forms.Application.StartupPath + @"\settings.xml"); }
public void Save(string sName, System.Xml.Linq.XElement xElement) { ValidateName(sName); xElement.Save(ToPath(sName)); }