title | description | ms.date | ms.assetid |
---|---|---|---|
ConfigurationSectionWithCollection.Add Method |
Details the syntax for the ConfigurationSectionWithCollection.Add method which adds an element to a collection in a configuration section. |
10/07/2016 |
ba05cc65-3f0e-35d5-f8a0-b4e3f82dc96e |
Adds an element to a collection in a configuration section.
ConfigurationSectionWithCollection.Add collectionName, element;
ConfigurationSectionWithCollection.Add collectionName, element
Name | Definition |
---|---|
collectionName |
A string value that contains the name of the collection that will be added to. |
element |
A CollectionElement object to which the element will be added. |
This method does not return a value.
When you use the Add
method, the changes you make are saved automatically. You do not need to use the Put_
method.
The following example adds a MIME map to the default Web site.
' 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
Type | Description |
---|---|
Client | - [!INCLUDEiis70] on [!INCLUDEwinvista] - [!INCLUDEiis75] on [!INCLUDEwin7] - [!INCLUDEiis80] on [!INCLUDEwin8] - [!INCLUDEiis100] on [!INCLUDEwin10] |
Server | - [!INCLUDEiis70] on [!INCLUDEwinsrv2008] - [!INCLUDEiis75] on [!INCLUDEwinsrv2008r2] - [!INCLUDEiis80] on [!INCLUDEwinsrv2012] - [!INCLUDEiis85] on [!INCLUDEwinsrv2012r2] - [!INCLUDEiis100] on [!INCLUDEwinsrv2016] |
Product | - [!INCLUDEiis70], [!INCLUDEiis75], [!INCLUDEiis80], [!INCLUDEiis85], [!INCLUDEiis100] |
MOF file | WebAdministration.mof |
CollectionElement Class
ConfigurationSectionWithCollection Class
MimeMapElement Class