Partager via


SPWeb.Delete Method

Deletes the Web site.

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

Syntax

Public Sub Delete

Dim instance As SPWeb

instance.Delete()
public void Delete()

Remarks

To delete a site collection, use the Delete method.

Examples

The following code example deletes a specified Web site.

Using siteCollection As New SPSite("http://localhost")
    Dim webSite As SPWeb = siteCollection.AllWebs("DeleteWebSite")
    webSite.Delete()

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

    oWebsite.Delete();
    oWebsite.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 Best Practices: Using Disposable Windows SharePoint Services Objects.

See Also

Reference

SPWeb Class

SPWeb Members

Microsoft.SharePoint Namespace