private void btAdd_Click(object sender, EventArgs e) { string temp = EagleAPI.egReadFile(System.Windows.Forms.Application.StartupPath + "\\options.XML"); XmlDocument xd = new XmlDocument(); xd.LoadXml(temp); XmlNode xn = xd.SelectSingleNode("eg"); xn = xn.SelectSingleNode("CommenCmds"); XmlNode xnAdd = xd.CreateElement("cmd"); xnAdd.InnerText = textBox1.Text; xn.AppendChild(xnAdd); xd.Save(System.Windows.Forms.Application.StartupPath + "\\options.XML"); this.Close(); }
private void btDelete_Click(object sender, EventArgs e) { string filename = System.Windows.Forms.Application.StartupPath + "\\options.XML"; string temp = EagleAPI.egReadFile(filename); XmlDocument xd = new XmlDocument(); xd.LoadXml(temp); XmlNode xn = xd.SelectSingleNode("eg"); xn = xn.SelectSingleNode("CommenCmds"); for (int i = 0; i < xn.ChildNodes.Count; i++) { if (lbCmds.SelectedItem.ToString() == xn.ChildNodes[i].InnerText) { xn.RemoveChild(xn.ChildNodes[i]); } } xd.Save(filename); CommenCmd_Load(sender, e); }
private void CommenCmd_Load(object sender, EventArgs e) { string filename = System.Windows.Forms.Application.StartupPath + "\\options.XML"; //FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); //StreamReader sr = new StreamReader(fs, Encoding.Default); //string temp = sr.ReadToEnd(); //sr.Close(); //fs.Close(); string temp = EagleAPI.egReadFile(filename); XmlDocument xd = new XmlDocument(); xd.LoadXml(temp); XmlNode xn = xd.SelectSingleNode("eg"); xn = xn.SelectSingleNode("CommenCmds"); lbCmds.Items.Clear(); for (int i = 0; i < xn.ChildNodes.Count; i++) { lbCmds.Items.Add(xn.ChildNodes[i].InnerText); } }