I'm attempting to delete a Site collection but receiving this error:
Microsoft.SharePoint.Client.ServerException: 'Cannot delete top-level site: https://{tenant}.sharepoint.com/teams/6KG9A4SO.'
public static void DeleteSite(NetworkCredential nc, string siteToDelete)
{
using (var cc = new ClientContext(siteToDelete))
{
cc.Credentials = new SharePointOnlineCredentials(nc.UserName, nc.SecurePassword);
// Delete the web object
cc.Web.DeleteObject();
// Execute the query to the server.
cc.ExecuteQuery();
}
}
What am I doing wrong?