//private: FluentFTP.IFtpClient CreateFtpClient() { FluentFTP.IFtpClient ftpClient; if (m_cxnParam.Proxy != null) { var proxy = new FluentFTP.Proxy.ProxyInfo(); proxy.Host = m_cxnParam.Proxy.Host; proxy.Port = m_cxnParam.Proxy.Port; ftpClient = new FluentFTP.Proxy.FtpClientHttp11Proxy(proxy); ftpClient.Host = m_cxnParam.Host; ftpClient.DataConnectionType = FluentFTP.FtpDataConnectionType.PASV; } else { ftpClient = new FluentFTP.FtpClient(m_cxnParam.Host); } if (m_cxnParam.Credential != null) { ftpClient.Credentials = new NetworkCredential(m_cxnParam.Credential.UserName, m_cxnParam.Credential.Password); } return(ftpClient); }
private StatusCode init() { StatusCode retVal = StatusCode.SUCCEED_STATUS; if (IsConnected) { return(retVal); } try { if (string.IsNullOrEmpty(_connectionInformation.ProxyHost)) { request = new FtpClient(_connectionInformation.ServerURL) { Port = _connectionInformation.Port }; } else { NetworkCredential proxyCredential = new NetworkCredential(_connectionInformation.ProxyUserID, _connectionInformation.ProxyPassword); FluentFTP.Proxy.ProxyInfo proxyInfo = new FluentFTP.Proxy.ProxyInfo() { Host = _connectionInformation.ProxyHost, Port = _connectionInformation.ProxyPort, Credentials = proxyCredential }; request = new FluentFTP.Proxy.FtpClientHttp11Proxy(proxyInfo) { Host = _connectionInformation.ProxyHost, Port = _connectionInformation.Port }; } request.SocketKeepAlive = false; request.DataConnectionType = _connectionInformation.IsPassive ? FtpDataConnectionType.AutoPassive : FtpDataConnectionType.AutoActive; request.EncryptionMode = _connectionInformation.SslEnabled ? (_connectionInformation.SslImplicit ? FtpEncryptionMode.Implicit : FtpEncryptionMode.Explicit) : FtpEncryptionMode.None; request.SslProtocols = _connectionInformation.SslEnabled ? System.Security.Authentication.SslProtocols.Tls : System.Security.Authentication.SslProtocols.None; if (_connectionInformation.SslEnabled) { request.ValidateCertificate += request_ValidateCertificate; } if (string.IsNullOrEmpty(_connectionInformation.UserID) == false) { string password = ""; if (string.IsNullOrEmpty(_connectionInformation.Password) == false) { password = _connectionInformation.Password; } request.Credentials = new NetworkCredential(_connectionInformation.UserID, password); } request.Connect(); } catch (Exception ex) { object[] args = new object[3]; args[0] = _connectionInformation.ServerURL; string user_id; string password; if (string.IsNullOrEmpty(_connectionInformation.UserID) == false) { user_id = _connectionInformation.UserID; password = ""; if (string.IsNullOrEmpty(_connectionInformation.Password) == false) { password = _connectionInformation.Password; } } else { user_id = ""; password = ""; } args[1] = user_id; args[2] = password; return(new Common.CommonStatusCode(CommonStatusCode.FTP_INITIALIZE_ERROR, args, ex, Config, ApplicationID)); } return(retVal); }