【发布时间】:2010-06-08 17:48:11
【问题描述】:
我正在尝试在我的 C# 控制台应用程序中使用配置文件。我通过新建 --> 应用程序配置文件在项目中创建了该文件,并将其命名为 myProjectName.config。我的配置文件如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SSDirectory" value="D:\Documents and Settings\****\MyDocuments\****" />
</appSettings>
</configuration>
访问它的代码如下所示:
private FileValidateUtil()
{
sSDirFilePath = ConfigurationSettings.AppSettings["SSDirectory"];
if (sSDirFilePath == null)
Console.WriteLine("config file not reading in.");
}
谁能提示一下为什么这不起作用? (我收到错误消息。)
谢谢!!
坏熊猫
【问题讨论】:
-
对大家的歧义感到抱歉。当我提到错误消息时,我的意思是 console.writeline 语句说“配置文件未读入”,我为造成的混乱道歉。
标签: c# file configuration singleton