Export (0) Print
Expand All
Add method (SPSiteCollectionAddParameters)
Expand Minimize

SPSiteCollection.Add method (String, String, String)

Creates an SPSite object based on the specified URL and on the user name and e-mail address of the owner of the site collection.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPSite Add(
	string siteUrl,
	string ownerLogin,
	string ownerEmail
)

Parameters

siteUrl
Type: System.String

A String that contains the URL for the site collection, for example, Site_Name or sites/Site_Name. It may either be server-relative or absolute for typical sites.

ownerLogin
Type: System.String

A String that contains the user name of the owner of the site collection (for example, Domain\User). In Active Directory Domain Services account creation mode, the ownerLogin parameter must contain a value even if the value does not correspond to an actual user name.

ownerEmail
Type: System.String

A String that contains the e-mail address of the owner of the site collection.

Return value

Type: Microsoft.SharePoint.SPSite
An SPSite object that represents the new site collection.

The following code example creates a site collection within a specified Web application.

SPWebApplication webApp = new SPSite("http://MySiteCollection").WebApplication;
SPSiteCollection siteCollections = webApp.Sites;

SPSite newSiteCollection = siteCollections.Add("sites/Site_Collection", 
    "DOMAIN\\User", "Email_Address");
Show:
© 2014 Microsoft