哪位大虾能提供一些用C#读写删改XML文件内容的资料啊?救小弟一命!! http://community.csdn.net/Expert/topic/3147/3147356.xml?temp=.589184
解决方案 »
- LINQtoSQL,SubmitChanges()方法没有把修改同步至数据库,怎么做
- PropertyGrid控件属性的保存问题
- csv 文件读取问题。
- 请问如何开发控件,并放入Visual Studio的工具箱中(内详)
- 怎样学习Javascript
- 关于DataSet
- 如何从数据库导出数据到xml并结合sheet显示到页面
- 在C#中定义类成员时加PRIVATE和什么都不加有区别吗?
- C# winform 事件
- 各位大侠告极了.如何把存储在ArrayList中的所有Point型的对象,还原为Point型?
- 我建立了一个WINFORM项目,在使用System.Management时,为什么编译器找不到???
- 用.net自带打包工具如何在用户程序菜单中生成快捷方式.
xDoc.Load(Application.ExecutablePath + ".config");
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2; xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='UserName']");
if ( xElem1 != null ) xElem1.SetAttribute("value",this.txtUserName.Text);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key","UserName");
xElem2.SetAttribute("value",this.txtUserName.Text);
xNode.AppendChild(xElem2);
}
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='Password']");
if ( xElem1 != null ) xElem1.SetAttribute("value",this.txtPassword.Text);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key","Password");
xElem2.SetAttribute("value",this.txtPassword.Text);
xNode.AppendChild(xElem2);
}
xDoc.Save(Application.ExecutablePath + ".config"); this.button1.Enabled = false;