private void RETR(string argsText) { if(m_SessionRejected){ WriteLine("500 Bad sequence of commands: Session rejected."); return; } if(!this.IsAuthenticated){ WriteLine("530 Please authenticate firtst !"); return; } if(string.IsNullOrEmpty(argsText)){ WriteLine("501 Invalid file name. !"); return; } /* This command causes the server-DTP to transfer a copy of the file, specified in the pathname, to the server- or user-DTP at the other end of the data connection. The status and contents of the file at the server site shall be unaffected. */ FTP_e_GetFile eArgs = new FTP_e_GetFile(argsText); OnGetFile(eArgs); // Error getting directory listing. if(eArgs.Error != null){ foreach(FTP_t_ReplyLine reply in eArgs.Error){ WriteLine(reply.ToString()); } } // Get file succeeded. else{ if(eArgs.FileStream == null){ WriteLine("500 Internal server error: File stream not provided by server."); return; } m_pDataConnection = new DataConnection(this,eArgs.FileStream,false); m_pDataConnection.Start(); } }
/// <summary> /// Raises <b>GetFile</b> event. /// </summary> /// <param name="e">Event data.</param> private void OnGetFile(FTP_e_GetFile e) { if(this.GetFile != null){ this.GetFile(this,e); } }