谁来教我下,对你应该很简单
[img=C:\Documents and Settings\Administrator\桌面][/img]初学者不知道哪里错了,谁告诉我这是怎么回事? --------------------编程问答-------------------- 问题呢???
教你神马?? --------------------编程问答-------------------- 图片看不见,是什么问题可以说说吗 --------------------编程问答-------------------- using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using System.Configuration;
using System.Xml;
namespace HotelCommunal
{
public class ConfingFile
{
private static string AppConfig()
{
string ss = AppDomain.CurrentDomain.BaseDirectory.ToString();
ss = ss.Substring(0, ss.Length - 10) + "App.config";
return ss;
}
public static void SetValue(string AppKey, string AppValue)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(ConfigFile);
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
{
xElem1.SetAttribute("value", AppValue);
}
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(ConfigFile.AppConfig());
}
}
}
运行时提示:上下文不存在名称为“configFile”
该怎么办啊》?
补充:.NET技术 , 非技术区