ConfigurationSectionWithCollection.Clear Method

Clears all elements from a collection in a configuration section.

Syntax

ConfigurationSectionWithCollection.Clear(collectionName);  
ConfigurationSectionWithCollection.Clear(collectionName)  

Parameters

Name Definition
collectionName A string value that contains the name of the collection to be removed.

Return Value

This method does not return a value.

Example

The following example clears the default documents, including all inherited default documents, for the default Web site. The code will cause the following XML to be added to the <system.webServer> section of the Web.config file for the default Web site:

<defaultDocument>

<files>

<clear />

</files>

</defaultDocument>

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the default Web site.  
Set oSite= oWebAdmin.Get("Site.Name='Default Web Site'")  
  
' Get the default documents section.  
oSite.GetSection "DefaultDocumentSection", oDefaultDocumentSection  
  
' Clear the default documents that are listed in the  
' DefaultDocumentSection.Files.Files property.  
oDefaultDocumentSection.Clear("Files.Files")  
  

Requirements

Type Description
Client - IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
MOF file WebAdministration.mof

See Also

ConfigurationSectionWithCollection Class
DefaultDocumentSection Class
FileSettings Class