当前位置:编程学习 > C#/ASP.NET >>

IIS7.0中怎么获取目录

我想获取iis的目录。用的是DirecotryEntry这个类,怎么也不能,总会报![System.Runtime.InteropServices.COMException]{"未知错误(0x80005000)"}错误。不知道有没有高手遇到过类似的问题。 
--------------------编程问答--------------------  TreeNode Node = null, SelectedNode = null;
            string strWebSiteName, strMetabasePath;
            WebSite.WebSiteState state;
            btn2.Focus();       // 先转移光标,避免闪烁

            if (0 == tv_MainIIS.Nodes.Count)                // an empty tree
            {
                Node = new TreeNode("LocalHost");
                Node.Name = "LocalHost";
                tv_MainIIS.Nodes.Add(Node);
            }
            if (null == tv_MainIIS.SelectedNode)            // No Selected Node
                tv_MainIIS.SelectedNode = tv_MainIIS.Nodes[0];

              tv_MainIIS.SelectedNode.Nodes.Clear();

            if (0 == tv_MainIIS.SelectedNode.Level)          // LocalHost
            {
                DirectoryEntry pde = new DirectoryEntry(ConstDef.LocalHost);

                foreach (DirectoryEntry de in pde.Children)
                {
                    if ("IIsWebServer" != de.SchemaClassName)
                        continue;

                    strWebSiteName = de.Properties["ServerComment"].Value.ToString();
                    Node = new TreeNode(strWebSiteName);
                    Node.Name = strWebSiteName;

                    switch (de.Properties["ServerState"].Value.ToString())
                    {
                        case "2": state = WebSite.WebSiteState.Running; break;
                        case "4": state = WebSite.WebSiteState.Stop; break;
                        case "6": state = WebSite.WebSiteState.Pause; break;
                        default: state = WebSite.WebSiteState.Error; break;
                    }
                    WebSiteTextRefresh(Node, state);

                    tv_MainIIS.SelectedNode.Nodes.Add(Node);
                    tv_MainIIS.SelectedNode = Node;
                    strMetabasePath = de.Path + "/Root";        // 站点的虚拟路径需要加"/Root"
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,