Partager via


SPSite(String) Constructor

The SPSite constructor initializes a new instance of the SPSite class based on the specified absolute URL.

Parameters

strUrl   A string that specifies the absolute URL for the site collection.

Remarks

The URL that is passed to the SPSite constructor does not need to match a site collection URL exactly. For example, the following snippet returns the site collection located at http://Server_Name/sites/Site_Name:

[Visual Basic .NET]

Dim siteCollection As New SPSite("http://Server_Name/sites/Site_Name/Subsite_Name/default.aspx")

[C#]

SPSite siteCollection = new SPSite("http://Server_Name/sites/Site_Name/Subsite_Name/default.aspx");

Example

The following code example creates an SPSite object.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security