ConfigurationSectionWithCollection.Add メソッド

構成セクションのコレクションに要素を追加します。

構文

ConfigurationSectionWithCollection.Add collectionName, element;  
ConfigurationSectionWithCollection.Add collectionName, element  

Parameters

名前 Definition
collectionName 追加するコレクションの名前を含む string 値。
element 要素の追加先となる CollectionElement オブジェクト。

戻り値

このメソッドは値を返しません。

解説

Add メソッドを使用すると、行った変更が自動的に保存されます。 Put_ メソッドを使用する必要はありません。

次の例では、MIME マップを既定の Web サイトに追加します。

' 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 static content section by using the GetSection method.  
oSite.GetSection "StaticContentSection", oStaticContentSection  
  
' Get the MimeMapElement class object.  
Set oMimeMapElement = oWebAdmin.Get("MimeMapElement")  
  
' Spawn a new instance of the MimeMapElement class.  
Set oNewMimeMap = oMimeMapElement.SpawnInstance_  
  
' Assign values to the FileExtension and MimeType properties.  
oNewMimeMap.FileExtension = "MyFileExtension"  
oNewMimeMap.MimeType = "application/MyApp"  
  
' Add the MIME map to the collection.  
oStaticContentSection.Add "StaticContent", oNewMimeMap  
  

要件

説明
クライアント - 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
Product - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF ファイル WebAdministration.mof

参照

CollectionElement クラス
ConfigurationSectionWithCollection クラス
MimeMapElement クラス