zoukankan      html  css  js  c++  java
  • Del site

      string SiteID = null;
                DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");
               
                    foreach (DirectoryEntry child in root.Children)
                    {
                        if (child.SchemaClassName == "IIsWebServer")
                        {
                            if (WebSiteName == child.Properties["servercomment"].Value.ToString())
                            {
                                 SiteID = child.Name.ToString();
                            }
                        }
                    }          
                try
                {
                    if (SiteID == null) return "error:该站点不存在.";

                    DirectoryEntry deRoot = new DirectoryEntry("IIS://localhost/W3SVC");
                    try
                    {
                        DirectoryEntry deVDir = new DirectoryEntry();
                        deRoot.RefreshCache();
                        deVDir = deRoot.Children.Find(SiteID, "IIsWebServer");
                        deRoot.Children.Remove(deVDir);

                        deRoot.CommitChanges();
                        deRoot.Close();
                        return "successful:删除站点" + WebSiteName + "成功!";
                    }
                    catch (System.Exception)
                    {
                        return "error:该站点不存在.";
                    }
                }
                catch (Exception e)
                {
                    return "error:删除站点失败." + e.Message;
                }

  • 相关阅读:
    菜鸡的Java笔记 第二十八
    菜鸡的Java笔记 第二十七
    菜鸡的Java笔记 第二十六
    菜鸡的Java笔记 第二十五 wrapperClass 包装类
    bzoj3238 [Ahoi2013]差异
    bzoj4516 [Sdoi2016]生成魔咒
    bzoj3998 [TJOI2015]弦论
    bzoj1965 [Ahoi2005]洗牌
    bzoj4896 [Thu Summer Camp2016]补退选
    bzoj5055 膜法师
  • 原文地址:https://www.cnblogs.com/greencolor/p/1792701.html
Copyright © 2011-2022 走看看