共用方式為


ConfigurationSectionWithCollection.Clear 方法

清除組態區段中集合中的所有專案。

語法

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

參數

名稱 定義
collectionName string值,其中包含要移除之集合的名稱。

傳回值

這個方法不會傳回值。

範例

下列範例會清除預設網站的預設檔,包括所有繼承的預設檔。 程式碼會導致下列 XML 新增至 <system.webServer> 預設網站的 Web.config 檔案區段:

<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")  
  

規格需求

類型 描述
Client - Windows Vista 上的 IIS 7.0
- Windows 7 上的 IIS 7.5
- Windows 8 上的 IIS 8.0
- Windows 10上的 IIS 10.0
伺服器 - Windows Server 2008 上的 IIS 7.0
- Windows Server 2008 R2 上的 IIS 7.5
- Windows Server 2012 上的 IIS 8.0
- Windows Server 2012 R2 上的 IIS 8.5
- Windows Server 2016上的 IIS 10.0
產品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 檔案 WebAdministration.mof

另請參閱

ConfigurationSectionWithCollection 類別
DefaultDocumentSection 類別
FileSettings 類別