Saturday, September 19, 2009

Programmatically Delete Site Collection

Title: Programmatically Delete Site Collection
Code:

void DeleteSiteCollection(string requestUrl, string siteUrl)
{
SPSite site = new SPSite(requestUrl);
SPWeb web = null;
try
{
SPWebApplication webapp = site.WebApplication;
web = site.OpenWeb();
SPSiteCollection spSites = webapp.Sites;
webapp.Sites.Delete(siteUrl);
}
finally
{

}
}

2 comments:

Prasad said...

hello,
i want to remove a user from a sitecollection what shud be the code used.can u pls post a saple one.
if i want to remove his permisions
also, while deleting, how cna i achieve.
thnx in advance
prasad

Srini Sistla said...

here you go...

http://codename-srini.blogspot.com/2010/02/delete-user-from-site-collection.html