开发者

How to check the particular section or key word exist in appconfig file

开发者 https://www.devze.com 2023-03-22 11:51 出处:网络
I have added my own section <section listen开发者_运维技巧ers> in my app.config file. How can I check, programmatically, if the new section exist?section = ConfigurationManager.GetSection(\"sec

I have added my own section <section listen开发者_运维技巧ers> in my app.config file.

How can I check, programmatically, if the new section exist?


section = ConfigurationManager.GetSection("sectionName") as SectionType

section will be null if the section isn't there.


You might want to have a look at How to: Create Custom Configuration Sections Using ConfigurationSection


You have to access it like a normal XML file.

        var config = XDocument.Load("App.Config");
        var element = config
            .Element("section");
        ...
0

精彩评论

暂无评论...
验证码 换一张
取 消