当前位置: 首页>>代码示例>>C#>>正文


C# DirectoryEntry.MoveNext方法代码示例

本文整理汇总了C#中System.DirectoryServices.DirectoryEntry.MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryEntry.MoveNext方法的具体用法?C# DirectoryEntry.MoveNext怎么用?C# DirectoryEntry.MoveNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.DirectoryServices.DirectoryEntry的用法示例。


在下文中一共展示了DirectoryEntry.MoveNext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetWebServer

        public IISWebServer GetWebServer(string sWerServerName)
        {
            DirectoryEntry directoryEntry3;

            IISWebServer iISWebServer = null;
            IEnumerator iEnumerator1 = new DirectoryEntry("IIS://localhost/W3SVC").Children.GetEnumerator();
            try
            {
                while (iEnumerator1.MoveNext())
                {
                    var directoryEntry2 = (DirectoryEntry) iEnumerator1.Current;
                    if (directoryEntry2.SchemaClassName == "IIsWebServer" &&
                        ((String) directoryEntry2.Properties["ServerComment"].Value).Equals(sWerServerName))
                    {
                        iISWebServer = new IISWebServer
                                           {
                                               iID = Convert.ToInt32(directoryEntry2.Name),
                                               sServerName = (String) directoryEntry2.Properties["ServerComment"].Value
                                           };
                        directoryEntry3 =
                            new DirectoryEntry(String.Concat("IIS://localhost/W3SVC/", iISWebServer.ID, "/Root"));
                        iISWebServer.sRootPath = directoryEntry3.Properties["Path"][0] as String;
                        var iEnumerator2 = directoryEntry3.Children.GetEnumerator();
                        try
                        {
                            while (iEnumerator2.MoveNext())
                            {
                                var directoryEntry4 = (DirectoryEntry) iEnumerator2.Current;
                                if (directoryEntry4.SchemaClassName.ToUpper() != "IIsWebVirtualDir".ToUpper()) continue;
                                var iISWebVirtualDirectory = new IISWebVirtualDirectory
                                                                 {
                                                                     _sPath =
                                                                         (String)
                                                                         directoryEntry4.Properties["Path"][0],
                                                                     _sName = directoryEntry4.Name,
                                                                     _isApplication =
                                                                         (String)
                                                                         directoryEntry4.Properties["AppRoot"][0] !=
                                                                         String.Concat("/LM/W3SVC/", iISWebServer.ID,
                                                                                       "/ROOT"),
                                                                     _iWebServerID = iISWebServer.ID
                                                                 };
                                AddWebDirectories(directoryEntry4, String.Concat("/", iISWebVirtualDirectory._sName),
                                                  iISWebVirtualDirectory.WebDirectories, iISWebServer.ID,
                                                  iISWebVirtualDirectory._sPath);
                                iISWebServer.VirtualDirectories.Add(iISWebVirtualDirectory);
                            }
                        }
                        finally
                        {
                            var iDisposable = iEnumerator2 as IDisposable;
                            if (iDisposable != null)
                            {
                                iDisposable.Dispose();
                            }
                        }
                        AddWebDirectories(directoryEntry3, "", iISWebServer.WebDirectories, iISWebServer.ID,
                                          iISWebServer.RootPath);
                        directoryEntry3.Dispose();
                        break;
                    }
                }
            }
            finally
            {
                var iDisposable = iEnumerator1 as IDisposable;
                if (iDisposable != null)
                {
                    iDisposable.Dispose();
                }
            }
            return iISWebServer;
        }
开发者ID:skitsanos,项目名称:WDK9,代码行数:73,代码来源:IISManager.cs

示例2: GetWebServers

 public IISWebServerCollection GetWebServers()
 {
     var iISWebServerCollection = new IISWebServerCollection();
     IEnumerator iEnumerator1 = new DirectoryEntry("IIS://localhost/W3SVC").Children.GetEnumerator();
     try
     {
         while (iEnumerator1.MoveNext())
         {
             var directoryEntry2 = (DirectoryEntry) iEnumerator1.Current;
             if (directoryEntry2.SchemaClassName != "IIsWebServer") continue;
             var iISWebServer = new IISWebServer
                                    {
                                        iID = Convert.ToInt32(directoryEntry2.Name),
                                        sServerName =
                                            (String) directoryEntry2.Properties["ServerComment"].Value
                                    };
             var directoryEntry3 =
                 new DirectoryEntry(String.Concat("IIS://localhost/W3SVC/", iISWebServer.ID, "/Root"));
             iISWebServer.sRootPath = directoryEntry3.Properties["Path"][0] as String;
             IEnumerator iEnumerator2 = directoryEntry3.Children.GetEnumerator();
             try
             {
                 while (iEnumerator2.MoveNext())
                 {
                     var directoryEntry4 = (DirectoryEntry) iEnumerator2.Current;
                     if (directoryEntry4.SchemaClassName.ToUpper() == "IIsWebVirtualDir".ToUpper())
                     {
                         var iISWebVirtualDirectory = new IISWebVirtualDirectory
                                                          {
                                                              _sPath =
                                                                  (String) directoryEntry4.Properties["Path"][0],
                                                              _sName = directoryEntry4.Name,
                                                              _isApplication =
                                                                  (String)
                                                                  directoryEntry4.Properties["AppRoot"][0] !=
                                                                  String.Concat("/LM/W3SVC/", iISWebServer.ID,
                                                                                "/ROOT"),
                                                              _iWebServerID = iISWebServer.ID
                                                          };
                         iISWebServer.VirtualDirectories.Add(iISWebVirtualDirectory);
                     }
                 }
             }
             finally
             {
                 var iDisposable = iEnumerator2 as IDisposable;
                 if (iDisposable != null)
                 {
                     iDisposable.Dispose();
                 }
             }
             iISWebServerCollection.Add(iISWebServer);
         }
     }
     finally
     {
         var iDisposable = iEnumerator1 as IDisposable;
         if (iDisposable != null)
         {
             iDisposable.Dispose();
         }
     }
     return iISWebServerCollection;
 }
开发者ID:skitsanos,项目名称:WDK9,代码行数:64,代码来源:IISManager.cs

示例3: GetFTPServers

 public IISFTPServerCollection GetFTPServers()
 {
     var iISFTPServerCollection = new IISFTPServerCollection();
     IEnumerator iEnumerator = new DirectoryEntry("IIS://localhost/MSFTPSVC").Children.GetEnumerator();
     try
     {
         while (iEnumerator.MoveNext())
         {
             var directoryEntry2 = (DirectoryEntry) iEnumerator.Current;
             if (directoryEntry2.SchemaClassName == "IIsFtpServer")
             {
                 var iISFTPServer = new IISFTPServer
                                        {
                                            iID = Convert.ToInt32(directoryEntry2.Name),
                                            sServerName =
                                                (String) directoryEntry2.Properties["ServerComment"].Value,
                                            bAllowAnonymous =
                                                (bool) directoryEntry2.Properties["AllowAnonymous"].Value,
                                            sGreetingMessage =
                                                (String) directoryEntry2.Properties["GreetingMessage"].Value,
                                            sExitMessage =
                                                (String) directoryEntry2.Properties["ExitMessage"].Value,
                                            sMaxClientsMessage =
                                                (String) directoryEntry2.Properties["MaxClientsMessage"].Value,
                                            iMaxConnections =
                                                (int) directoryEntry2.Properties["MaxConnections"].Value
                                        };
                 var directoryEntry3 =
                     new DirectoryEntry(String.Concat("IIS://localhost/MSFTPSVC/", iISFTPServer.ID, "/Root"));
                 iISFTPServer.sRootPath = directoryEntry3.Properties["Path"][0] as String;
                 iISFTPServerCollection.Add(iISFTPServer);
             }
         }
     }
     finally
     {
         var iDisposable = iEnumerator as IDisposable;
         if (iDisposable != null)
         {
             iDisposable.Dispose();
         }
     }
     return iISFTPServerCollection;
 }
开发者ID:skitsanos,项目名称:WDK9,代码行数:44,代码来源:IISManager.cs


注:本文中的System.DirectoryServices.DirectoryEntry.MoveNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。