Esempio n. 1
0
 /// <summary>
 /// Initializes the parameters.
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 private void InitializeParameters(FtpClientParameters parameters)
 {
     if (parameters == null)
     {
         parameters = DefaultParameters;
     }
     if (!parameters.Passive && parameters.ProxyConnect != null)
     {
         throw new InvalidOperationException("Active transfer mode only works without proxy server");
     }
     Passive            = parameters.Passive;
     ActiveTransferHost = parameters.ActiveTransferHost;
     ConnectTimeout     = parameters.ConnectTimeout;
     ReadWriteTimeout   = parameters.ReadWriteTimeout;
     SessionTimeout     = parameters.SessionTimeout;
     AnonymousPassword  = parameters.AnonymousPassword;
     DefaultEncoding    = parameters.DefaultEncoding;
     ProxyConnect       = parameters.ProxyConnect;
     ChannelProtection  = parameters.ChannelProtection ?? GetDefaultDataChannelProtection(Uri);
     SslProtocols       = parameters.SslProtocols ?? SslProtocols.Ssl3 | SslProtocols.Tls;
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FtpClient"/> class.
 /// </summary>
 /// <param name="uri">The URI.</param>
 /// <param name="credential">The credential.</param>
 /// <param name="parameters">The parameters.</param>
 public FtpClient(Uri uri, NetworkCredential credential, FtpClientParameters parameters = null)
     : this(GetProtocol(uri), uri.Host, GetPort(uri), credential, parameters)
 {
 }
Esempio n. 3
0
        /// <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();
        }