Exemple #1
0
        public IISFTPServer GetFTPServer(string sWerServerName)
        {
            DirectoryEntry directoryEntry2;

            DirectoryEntry directoryEntry3;

            IISFTPServer iISFTPServer = null;
            var          iEnumerator  = new DirectoryEntry("IIS://localhost/MSFTPSVC").Children.GetEnumerator();

            try
            {
                while (iEnumerator.MoveNext())
                {
                    directoryEntry2 = (DirectoryEntry)iEnumerator.Current;
                    if (directoryEntry2.SchemaClassName == "IIsFtpServer" &&
                        ((String)directoryEntry2.Properties["ServerComment"].Value).Equals(sWerServerName))
                    {
                        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
                        };
                        directoryEntry3 =
                            new DirectoryEntry(String.Concat("IIS://localhost/MSFTPSVC/", iISFTPServer.ID, "/Root"));
                        iISFTPServer.sRootPath = directoryEntry3.Properties["Path"][0] as String;
                        break;
                    }
                }
            }
            finally
            {
                var iDisposable = iEnumerator as IDisposable;
                if (iDisposable != null)
                {
                    iDisposable.Dispose();
                }
            }
            return(iISFTPServer);
        }
Exemple #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;
 }
 public void Remove(IISFTPServer value)
 {
     List.Remove(value);
 }
 public void Insert(int index, IISFTPServer value)
 {
     List.Insert(index, value);
 }
 public int IndexOf(IISFTPServer value)
 {
     return List.IndexOf(value);
 }
 public bool Contains(IISFTPServer value)
 {
     return List.Contains(value);
 }
 public int Add(IISFTPServer value)
 {
     return List.Add(value);
 }
 public bool Contains(IISFTPServer value)
 {
     return(List.Contains(value));
 }
 public void Remove(IISFTPServer value)
 {
     List.Remove(value);
 }
 public void Insert(int index, IISFTPServer value)
 {
     List.Insert(index, value);
 }
 public int IndexOf(IISFTPServer value)
 {
     return(List.IndexOf(value));
 }
 public int Add(IISFTPServer value)
 {
     return(List.Add(value));
 }