private void button1_Click(object sender, EventArgs e)
{
string xmlfile = AppDomain.CurrentDomain.BaseDirectory + @"\Dcms.Crm.UI.exe.config";
XmlDocument xmdoc = new XmlDocument();
xmdoc.Load(xmlfile);
XmlNodeList nodelist = xmdoc.SelectSingleNode("/configuration/appSettings").ChildNodes;
if (this.radioButton1.Checked == true)
{
foreach (XmlNode xn in nodelist)
{
XmlElement xe = (XmlElement)xn;
if (xe.GetAttribute("key") == "ServerURL")
{
xe.SetAttribute("value", "http://" + this.textBox4.Text + "/" + textBox2.Text);
break;
} }
}
else if (this.radioButton2.Checked == true)
{
foreach (XmlNode xn in nodelist)
{
XmlElement xe = (XmlElement)xn;
if (xe.GetAttribute("key") == "ServerURL")
{
xe.SetAttribute("value", "http://" + this.textBox3.Text + "/" + textBox2.Text);
break;
} }
}
}xml文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings file="">
<clear />
<add key="LocalDbSource" value="Provider='Microsoft.Jet.OLEDB.4.0'; Data Source='c:\\CrmTest.mdb'" />
<add key="FileNeedReset" value="Y" />
<add key="SyncServerName" value="127.0.0.1" />
<add key="RemotePort" value="8043" />
<add key="ConnectType" value="Dcms.Common.ConnectWebService, Dcms.Common" />
<add key="ServerURL" value="http://192.168.1.199/Dcms.Server.ZhiZhong.WebService/GeneralWebService.asmx" />
</appSettings>
{
string xmlfile = AppDomain.CurrentDomain.BaseDirectory + @"\Dcms.Crm.UI.exe.config";
XmlDocument xmdoc = new XmlDocument();
xmdoc.Load(xmlfile);
XmlNodeList nodelist = xmdoc.SelectSingleNode("/configuration/appSettings").ChildNodes;
if (this.radioButton1.Checked == true)
{
foreach (XmlNode xn in nodelist)
{
XmlElement xe = (XmlElement)xn;
if (xe.GetAttribute("key") == "ServerURL")
{
xe.SetAttribute("value", "http://" + this.textBox4.Text + "/" + textBox2.Text);
break;
} }
}
else if (this.radioButton2.Checked == true)
{
foreach (XmlNode xn in nodelist)
{
XmlElement xe = (XmlElement)xn;
if (xe.GetAttribute("key") == "ServerURL")
{
xe.SetAttribute("value", "http://" + this.textBox3.Text + "/" + textBox2.Text);
break;
} }
}
}xml文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings file="">
<clear />
<add key="LocalDbSource" value="Provider='Microsoft.Jet.OLEDB.4.0'; Data Source='c:\\CrmTest.mdb'" />
<add key="FileNeedReset" value="Y" />
<add key="SyncServerName" value="127.0.0.1" />
<add key="RemotePort" value="8043" />
<add key="ConnectType" value="Dcms.Common.ConnectWebService, Dcms.Common" />
<add key="ServerURL" value="http://192.168.1.199/Dcms.Server.ZhiZhong.WebService/GeneralWebService.asmx" />
</appSettings>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货