[导入]NameValueSectionHandler 和 DictionarySectionHandler 的 <remove> 元素移除一项以前定义的设置
移除一项以前定义的设置。
<configuration>
<sectionName>
<remove>
<remove key="predefened setting key"/>
必选属性
| 属性 | 说明 |
|---|---|
| key | 指定要移除的设置的键名。 |
备注
可使用 <remove> 元素从应用程序中移除在配置文件层次结构的更高级别定义的设置。
示例
下面的示例说明如何在应用程序配置文件中使用 <remove> 元素移除以前在计算机配置文件中定义的设置。
下面的计算机配置文件代码声明 <mySection> 这一节并向其添加两个设置:key1 和 key2。
<!-- Machine.config file. -->
<configuration>
<configSections>
<section name="mySection"
type="System.Configuration.NameValueSectionHandler,System" />
</sectionGroup>
</configSections>
<mySection>
<add key="key1" value="value1" />
<add key="key2" value="value2" />
</mySection>
</configuration>
下面的应用程序配置文件代码从 <mySection> 中移除 key2 设置。
<!--Application configuration file. -->
<configuration>
<mySection>
<remove key="key2"/>
</mySection>
</configuration>
配置文件
此元素可用于应用程序目录级以外的应用程序配置文件、计算机配置文件 (Machine.config) 和 Web.config 文件中
文章来源:http://www.codeguru.cn/ShowThread.aspx?PostID=731
浙公网安备 33010602011771号