Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 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;
 }