Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

SPWeb.Delete method

Deletes the website.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
[ClientCallableMethodAttribute(Name = "DeleteObject", RemoveThisObjectFromParentCollection = true)]
public void Delete()
ExceptionCondition
SPException

The deleting website is a root website.

To delete a site collection, use the Delete method.

The following code example deletes a specified website.

using (SPSite oSiteCollection = new SPSite("http://Site_Name"))
{
    SPWeb oWebsite = oSiteCollection.AllWebs["DeleteWebSite"];

    oWebsite.Delete();
    oWebsite.Dispose();
}
NoteNote

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.

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.