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

  • 相关阅读:
    扫雷游戏
    打地鼠Demo
    Game2048
    蛇形矩阵
    约瑟夫环
    二分法查找
    动态规划之防卫导弹
    动态规划之0-1背包问题
    回溯算法之火力网
    回溯算法之8皇后问题
  • 原文地址:https://www.cnblogs.com/greencolor/p/1792701.html
Copyright © 2011-2022 走看看