検索してもなかなか見つからなかったので、いろいろ試してみたらできました。
public static void DeleteWebSite(string machineName, string webSiteName)
{
IisWebSite webSite = GetSite(machineName, webSiteName);
if (webSite == null)
{
throw new Exception(String.Format("Site {0} does not exist.", webSiteName));
}
string IISPath = String.Format(IIS_ROOT, machineName) + "/" + webSite.Id;
DirectoryEntry de = new DirectoryEntry(IISPath);
de.RefreshCache();
de.DeleteTree();
de.Close();
}

最近のコメント