If you have ever tried to delete a web either in code, or via the SharePoint GUI, then you will note that isn't possible if the web has one or more child webs. (or grandchildren). To delete a web, you must first delete it's subwebs.
The code below illustrates this in C# :
public static bool DeleteWeb(SPWeb parentWeb, string webUrl, bool deleteSubWebs)
{ try
{ SPWeb webToDelete = parentWeb.Webs[webUrl];
if (webToDelete != null)
{ if (deleteSubWebs)
{ DeleteSubWebs(webToDelete.Webs);
}
webToDelete.Delete();
}
LogHelper.LogMethodEnd(logger, "SPWebHelper", "DeleteWeb");
return true;
}
catch (Exception ex)
{ return false;
}
}
private static void DeleteSubWebs(SPWebCollection webs)
{ LogHelper.LogMethodStart(logger, "SPWebHelper", "DeleteSubWebs");
foreach (SPWeb web in webs)
{ if (web.Webs.Count > 0)
DeleteSubWebs(web.Webs);
web.Delete();
}
LogHelper.LogMethodEnd(logger, "SPWebHelper", "DeleteSubWebs");
}