在我的项目中,我有两个应用配置文件,分别为 app.config
和 accessLevel.config
。 现在使用 OpenExeConfiguration
方法,我能够访问 app.config.exe
文件,但无法访问 accessLevel.config
文件。请帮忙解决。
我有两个配置文件的主要原因是为了展示它们之间的区别,并使代码简单化。
我需要在我的 C#
代码中读取 accessLevel.config
文件的值。
尝试了以下代码但没有用:
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.File = "App2.config";
app.config.exe
中加入这行代码吗? - Praveen<appSettings />
元素开头,而不是默认的<configuration />
元素。我花了大约10分钟才意识到这一点;) - Jan 'splite' K.