SPSiteCollection Class
The SPSiteCollection class represents a collection of SPSite objects, or site collections, on a virtual server.
System.Object
Microsoft.SharePoint.Administration.SPSiteCollection
Public Methods
The following table shows the public methods of the SPSiteCollection class and a brief description of each.
| Name | Description |
|---|---|
| Add(String, String, String) | Creates a site object based on the specified URL and on the user name and e-mail address of the owner for the site object. |
| Add(String, String, String, Int32, String, String, String, String) | Creates a site object in the collection based on the specified site URL, Web site title, description, locale identifier, and site definition or site template, as well as on the user name, user display name, and e-mail address of the owner for the site object. |
| Add(String, String, String, Int32, String, String, String, String, String, String, String) | Creates a site object in the collection based on the specified site URL, Web site title, description, locale identifier, and site definition or site template, as well as on the user names, user display names, and e-mail addresses of both the owner and a secondary contact. |
| Add(String, String, String, Int32, String, String, String, String, String, String, String, String, String, String, String) | Creates a site object in the collection based on the specified site URL, Web site title, description, locale identifier, and site definition or site template, as well as on the user names, user display names, and e-mail addresses of both the owner and a secondary contact, and on the database server, name for the new database, and the user name and password of the database administrator. |
| Backup | Creates a backup file for the site object located at the specified URL. |
| Delete(String) | Deletes the SPSite object with the specified URL from the collection. |
| Delete(String, Boolean) | Deletes the SPSite object with the specified server-relative URL from the collection and removes the site collection users from the Active Directory directory service if bDeleteADAccounts is true. This method is only intended for use in Active Directory account creation mode. |
| Restore | Restores a site object to the specified URL from the specified backup file. |
Public Properties
The following table shows the public properties of the SPSiteCollection class, the data type of each property, and a brief description of each.
| Name | Data Type | Description |
|---|---|---|
| Count | Int32 | Gets the number of site objects in the collection. |
| Item(Int32) | Microsoft.SharePoint.SPSite | Gets the site object at the specified index in the collection. |
| Item(String) | Microsoft.SharePoint.SPSite | Gets the site object at the specified server-relative URL from the collection. |
| Names | String[] | Gets the server-relative URLs of all the site objects in the collection. |
| VirtualServer | Microsoft.SharePoint.Administration.SPVirtualServer | Gets the parent virtual server for the collection. |
Thread Safety
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
Remarks
Use the Sites property of the SPVirtualServer class to return a collection of SPSite objects that represent all the site collections on a virtual server. To create a site collection, use one of the Add methods represented in the first table.
Use an indexer to return a single site object from the collection. For example, if the collection is assigned to a variable named mySites, use mySites[index] in C#, or mySites(index) in Visual Basic .NET, where index is either the index number of the site object in the collection or the display name of the site.
Requirements
Namespace: Microsoft.SharePoint.Administration
Platforms: Microsoft Windows Server 2003
Assembly: Windows SharePoint Services (in Microsoft.SharePoint.dll)
Security: Code Access Security