Share via


SPSite.Delete Method

Deletes the site collection from the server.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.PerSpec)> _
Public Sub Delete
'Usage
Dim instance As SPSite

instance.Delete()
[SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.PerSpec)]
public void Delete()

Examples

The following code example illustrates how to use the Delete method.

Dim siteCollection As New SPSite("http://" + 
    System.Environment.MachineName + "/sites/Site_Collection")

siteCollection.Delete()
siteCollection.Dispose()
SPSite oSiteCollection = new SPSite("http://" + 
    System.Environment.MachineName + "/sites/Site_Collection");

oSiteCollection.Delete();
oSiteCollection.Dispose();

Note

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

See Also

Reference

SPSite Class

SPSite Members

Delete Overload

Microsoft.SharePoint Namespace