我正在使用这个类写入配置文件.代码已建立且应用程序启动,但每次检查app.config时,我都看不到任何内容.
可能是什么问题呢?
这是代码:
public class ConfigSettings
{
private ConfigSettings() { }
public static string ReadSetting(string key)
{
return ConfigurationManager.AppSettings[key];
}
public static void WriteSetting(string key, string value)
{
// load config document for current assembly
XmlDocument doc = loadConfigDocument();
// retrieve appSettings node
XmlNode node = doc.SelectSingleNode("//appSettings");
if (node == null)
throw new InvalidOperationException("appSettings section not found in config file.");
try
{
// select the 'add' element that contains the key
XmlElement elem = (XmlElement)node.SelectSingleNode(string.Format("//add[@key='{0}']", key));
if (elem != null) …Run Code Online (Sandbox Code Playgroud)