/// <summary> /// Releases the unmanaged resources used by the <see cref="FtpSessionConnected"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!m_disposed) { try { // This will be done regardless of whether the object is finalized or disposed. if (disposing) { m_host = null; m_root = null; m_current = null; if ((object)m_ctrlChannel != null) { m_ctrlChannel.Close(); } m_ctrlChannel = null; if ((object)m_dataStream != null) { m_dataStream.Dispose(); } m_dataStream = null; } } finally { m_disposed = true; // Prevent duplicate dispose. } } }
internal FtpSessionConnected(FtpClient h, FtpControlChannel ctrl, bool caseInsensitive) { m_host = h; m_ctrlChannel = ctrl; m_ctrlChannel.Session = this; m_caseInsensitive = caseInsensitive; }
public void Connect(string userName, string password) { FtpControlChannel ctrl = new FtpControlChannel(m_host); ctrl.Server = m_server; ctrl.Port = m_port; ctrl.Connect(); try { ctrl.Command("USER " + userName); if (ctrl.LastResponse.Code == FtpResponse.UserAcceptedWaitingPass) { ctrl.Command("PASS " + password); } if (ctrl.LastResponse.Code != FtpResponse.UserLoggedIn) { throw new FtpAuthenticationException("Failed to login.", ctrl.LastResponse); } m_host.State = new FtpSessionConnected(m_host, ctrl, m_caseInsensitive); ((FtpSessionConnected)m_host.State).InitRootDirectory(); } catch { ctrl.Close(); throw; } }
internal FtpDataStream(FtpControlChannel ctrl, TcpClient client) { m_session = ctrl.Session; m_ctrl = ctrl; m_tcpClient = client; m_stream = client.GetStream(); m_session.BeginDataTransfer(this); }
internal FtpDataStream(FtpControlChannel ctrl, TcpClient client) { m_session = ctrl.Session; m_ctrl = ctrl; m_tcpClient = client; m_stream = client.GetStream(); m_stream.ReadTimeout = ctrl.Timeout; m_stream.WriteTimeout = ctrl.Timeout; TryBeginDataTransfer(); }
internal FtpInputDataStream(FtpControlChannel ctrl, TcpClient client) : base(ctrl, client) { }
internal FtpOutputDataStream(FtpControlChannel ctrl, TcpClient client) : base(ctrl, client) { }
/// <summary> /// Releases the unmanaged resources used by the <see cref="FtpSessionConnected"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!m_disposed) { try { // This will be done regardless of whether the object is finalized or disposed. if (disposing) { m_host = null; m_root = null; m_current = null; if ((object)m_ctrlChannel != null) m_ctrlChannel.Close(); m_ctrlChannel = null; if ((object)m_dataStream != null) m_dataStream.Dispose(); m_dataStream = null; } } finally { m_disposed = true; // Prevent duplicate dispose. } } }
public void Connect(string userName, string password) { FtpControlChannel ctrl = new FtpControlChannel(m_host); ctrl.Server = m_server; ctrl.Port = m_port; ctrl.Connect(); try { ctrl.Command("USER " + userName); if (ctrl.LastResponse.Code == FtpResponse.UserAcceptedWaitingPass) ctrl.Command("PASS " + password); if (ctrl.LastResponse.Code != FtpResponse.UserLoggedIn) throw new FtpAuthenticationException("Failed to login.", ctrl.LastResponse); m_host.State = new FtpSessionConnected(m_host, ctrl, m_caseInsensitive); ((FtpSessionConnected)m_host.State).InitRootDirectory(); } catch { ctrl.Close(); throw; } }