Process pro = new Process();
string propath = System.AppDomain.CurrentDomain.BaseDirectory;
string t_data = "";
string t_sa = "";
string t_pwd = "";
private void button1_Click(object sender, EventArgs e)
{
//
// 写入 xml
string xmlpath = System.AppDomain.CurrentDomain.BaseDirectory + "setting.xml";
XmlDocument xdoc = new XmlDocument();
xdoc.Load(xmlpath);
XmlElement root = xdoc.DocumentElement;
//* ***创建节点****
//XmlElement company = xdoc.CreateElement("company");
//root.AppendChild(company);
//XmlElement cid = xdoc.CreateElement("cid");
//XmlElement xcname = xdoc.CreateElement("cname");
//XmlElement xpname = xdoc.CreateElement("pname");
//XmlElement xphnum = xdoc.CreateElement("phnum");
//XmlElement xidnum = xdoc.CreateElement("idnum");
//xcname.InnerText = dwmc.Text.ToString();
//xpname.InnerText = pname.Text;
//xphnum.InnerText = pname.Text;
//xidnum.InnerText = textBox4.Text;
//company.AppendChild(cid);
//company.AppendChild(xcname);
//company.AppendChild(xpname);
//company.AppendChild(xphnum);
//company.AppendChild(xidnum);
//*****
XmlNodeList nlist = xdoc.SelectNodes("Mjdesign/company");
if (nlist!=null)
{
foreach (XmlNode msnode in nlist)
{
XmlNodeList mlist = msnode.ChildNodes;
foreach (XmlNode nsnode in mlist)
{
// MessageBox.Show(nsnode.Name);
if (nsnode.Name == "cname")
{
XmlElement xe = (XmlElement)nsnode;
xe.InnerText = dwmc.Text;
xdoc.Save(xmlpath);
//MessageBox.Show(dwmc.Text);
}
if (nsnode.Name == "pname")
{
XmlElement xe = (XmlElement)nsnode;
xe.InnerText = pname.Text;
xdoc.Save(xmlpath);
}
if (nsnode.Name == "phnum")
{
XmlElement xe = (XmlElement)nsnode;
xe.InnerText = phnum.Text;
xdoc.Save(xmlpath);
}
if (nsnode.Name == "idnum")
{
XmlElement xe = (XmlElement)nsnode;
xe.InnerText = pnum.Text;
xdoc.Save(xmlpath);
}
if (nsnode.Name == "proname")
{
XmlElement xe = (XmlElement)nsnode;
xe.InnerText = xmmc.Text;
xdoc.Save(xmlpath);
}
}
}
}
if (radioButton1.Checked == true)
{
pro.StartInfo.WorkingDirectory = propath + "R1";
pro.StartInfo.FileName = "R1.exe";
pro.StartInfo.UseShellExecute = true;
pro.Start();
this.FindForm().Close();
}
if (radioButton2.Checked == true)
{
pro.StartInfo.WorkingDirectory = propath + "R2";
pro.StartInfo.FileName = "R2.exe";
pro.StartInfo.UseShellExecute = true;
pro.Start();
this.FindForm().Close();
}
if (radioButton3.Checked == true)
{
pro.StartInfo.WorkingDirectory = propath + "R3";
pro.StartInfo.FileName = "R3.exe";
pro.StartInfo.UseShellExecute = true;
pro.Start();
this.FindForm().Close();
}
if (radioButton4.Checked == true)
{
pro.StartInfo.WorkingDirectory = propath + "R4";
pro.StartInfo.FileName = "R4.exe";
pro.StartInfo.UseShellExecute = true;
pro.Start();
this.FindForm().Close();
}
if (radioButton5.Checked == true)
{
pro.StartInfo.WorkingDirectory = propath + "R5";
pro.StartInfo.FileName = "R5.exe";
pro.StartInfo.UseShellExecute = true;
pro.Start();
this.FindForm().Close();
}
if (radioButton6.Checked == true)
{
pro.StartInfo.WorkingDirectory = propath + "R6";
pro.StartInfo.FileName = "R6.exe";
pro.StartInfo.UseShellExecute = true;
pro.Start();
this.FindForm().Close();
}
if (radioButton7.Checked == true)
{
pro.StartInfo.WorkingDirectory = propath + "R7";
pro.StartInfo.FileName = "R7.exe";
pro.StartInfo.UseShellExecute = true;
pro.Start();
this.FindForm().Close();
}
}
标签:XML,xdoc,04,项目,pro,nsnode,XmlElement,StartInfo,true From: https://www.cnblogs.com/lionmxs/p/18148216