如何从c#代码中读取配置文件中的节
在通过c#读取配置部分时,我在第1行中得到一个错误如何从c#代码中读取配置文件中的节,c#,C#,在通过c#读取配置部分时,我在第1行中得到一个错误 此处不允许应用程序相对虚拟路径“~”。 System.Configuration.Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); SystemWebSectionGroup grp = (SystemWebSectionGroup)config.GetSectionGroup("sys
此处不允许应用程序相对虚拟路径“~”。
System.Configuration.Configuration config =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
SystemWebSectionGroup grp = (SystemWebSectionGroup)config.GetSectionGroup("system.web");
我的猜测是,调用OpenWebConfiguration时不允许使用“~”的值,但这只是阅读错误消息时的猜测。OpenWebConfiguration()的文档中说,如果您想要根web.config,就要传递
null
。您是否也可以显示配置文件中的部分