void ProgramStart(object item) { string filename = "D://WhiteXML.xml"; if (!File.Exists(filename)) { XmlDocument doc = new XmlDocument(); XmlElement rootElement = doc.CreateElement("root"); doc.AppendChild(rootElement); XmlNode xn = doc.SelectSingleNode("root"); XmlElement childElement = doc.CreateElement("WhiteList"); XmlElement URLElement = doc.CreateElement("URL"); URLElement.InnerText = " "; childElement.AppendChild(URLElement); rootElement.AppendChild(childElement); doc.Save(filename); XMLDAL.Insert(" "); } XmlDocument readxml = new XmlDocument(); readxml.Load(filename); XmlElement xnn = readxml.DocumentElement; ReadX(xnn); }
private void BT_Add_Click(object sender, EventArgs e) { if (tb_add_white.Text != string.Empty) { XMLDAL.Insert(tb_add_white.Text); Load_WhiteList(); } else { MessageBox.Show("请填写添加项!"); } }
private void BT_Del_Click(object sender, EventArgs e) { XmlDocument delxml = new XmlDocument(); delxml.Load(filename); XmlNode rootnode = delxml.DocumentElement; string del_url = ""; del_url = LB_White.SelectedItem.ToString(); if (MessageBox.Show("确定要将" + del_url + "移除白名单?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { XMLDAL.Delete(rootnode, del_url); MessageBox.Show("已将" + del_url + "移除白名单"); delxml.Save(filename); Load_WhiteList(); } }