Go back to index
How to delete site collection
Following code block explains how to programmatically delete a site collection from a web application.
using System;
using SPTool.Library;
using System.Collections.ObjectModel;
namespace SPTool.Test
{
class Program
{
static void Main(string[] args)
{
SPTWebApplication webApplication = new SPTWebApplication("http://sptool/");
// Delete Site Collection
SPTReturn returnObj = webApplication.DeleteSiteCollection("/");
// Check the status of site collection deletion
if (returnObj.State == SPTState.Success)
{
// Successfully deleted site collection
}
else
{
// Deleting site collection failed
}
}
}
}
Go back to index