예제 #1
0
파일: FtpClient.cs 프로젝트: kin988g/FTP
        /// <summary>
        /// Initializes a new instance of the <see cref="FtpClient"/> class.
        /// </summary>
        /// <param name="protocol">The protocol.</param>
        /// <param name="host">The host.</param>
        /// <param name="port">The port.</param>
        /// <param name="credential">The credential.</param>
        /// <param name="parameters">The parameters.</param>
        public FtpClient(FtpProtocol protocol, string host, int port, NetworkCredential credential, FtpClientParameters parameters = null)
        {
            Credential = credential;
            Protocol   = protocol;
            Port       = port;
            var uriBuilder = new UriBuilder {
                Scheme = GetScheme(protocol), Host = host, Port = port
            };

            Uri = uriBuilder.Uri;
            InitializeParameters(parameters);
            _connectionsThread = new Thread(ConnectionThread)
            {
                IsBackground = true, Name = "FtpClient.SessionThread"
            };
            _connectionsThread.Start();
        }
예제 #2
0
파일: FtpClient.cs 프로젝트: kin988g/FTP
        /// <summary>
        /// Gets the scheme.
        /// </summary>
        /// <param name="protocol">The protocol.</param>
        /// <returns></returns>
        private static string GetScheme(FtpProtocol protocol)
        {
            switch (protocol)
            {
            case FtpProtocol.Ftp:
                return(Uri.UriSchemeFtp);

            case FtpProtocol.FtpS:
                return("ftps");

            case FtpProtocol.FtpES:
                return("ftpes");

            default:
                throw new ArgumentOutOfRangeException("protocol");
            }
        }
예제 #3
0
 public FtpClient(FtpProtocol protocol, string host, int port, NetworkCredential credentials,
                  Parameters.FtpClientParameters parameters)
 {
     // Inicializa los objetos
     Commands = new FtpClientCommands(this);
     // Asigna los parámetros
     Credential = credentials;
     Protocol   = protocol;
     Port       = port;
     Uri        = new UriBuilder {
         Scheme = GetScheme(protocol), Host = host, Port = port
     }.Uri;
     // Inicializa los parámetros de cliente
     if (parameters == null)
     {
         ClientParameters = new Parameters.FtpClientParameters(true);
     }
     else
     {
         ClientParameters = parameters;
     }
     // Crea la conexión
     Connection = new Sessions.FtpConnection(this);
 }