広告

IISのWebSiteをC#で削除する

検索してもなかなか見つからなかったので、いろいろ試してみたらできました。

        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();
        }

返信

 

 

 

以下の HTMLタグ を使うことができます。

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>