修改配置文件参数.config
#region 读取XML
/// <summary>
/// 读取XML
/// </summary>
/// <param name="hscode"></param>
/// <returns></returns>
private void SelectXML()
{
XmlDocument XMLDoc = new XmlDocument();
XMLDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "/ts.exe.config");
//修改数据库服务器的IP地址和用户名和密码(ts.exe.config)
XmlNodeList list = XMLDoc.GetElementsByTagName("add");
for (int i = 0; i < list.Count; i++)
{
if (list[i].Attributes[0].Value == "SQL2005")
{
string IpS = this.txtIP.Text;
string IpName = this.txtName.Text;
string IpPass = this.txtPass.Text;
string Ip2 = "Data Source=" + IpS + ";Initial Catalog=ScanNingSystem; User id = " + IpName + ";password = " + IpPass + "";
list[i].Attributes[1].Value = Ip2;//在这里改
break;
}
}
StreamWriter swriter = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "/ts.exe.config");
XmlTextWriter xw = new XmlTextWriter(swriter);
xw.Formatting = Formatting.Indented;
XMLDoc.WriteTo(xw);
xw.Close();
swriter.Close();
MessageBox.Show("数据库服务器参数设置成功!", "输入提示");
Application.Exit();
}
#endregion