private void SIZE(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."); } /* RFC 3659 4.1. The syntax of the SIZE command is: size = "Size" SP pathname CRLF The server-PI will respond to the SIZE command with a 213 reply giving the transfer size of the file whose pathname was supplied, or an error response if the file does not exist, the size is unavailable, or some other error has occurred. The value returned is in a format suitable for use with the RESTART (REST) command for mode STREAM, provided the transfer mode and type are not altered. size-response = "213" SP 1*DIGIT CRLF / error-response Note that when the 213 response is issued, that is, when there is no error, the format MUST be exactly as specified. Multi-line responses are not permitted. */ FTP_e_GetFileSize eArgs = new FTP_e_GetFileSize(argsText); OnGetFileSize(eArgs); // Error completing operation. if(eArgs.Error != null){ foreach(FTP_t_ReplyLine reply in eArgs.Error){ WriteLine(reply.ToString()); } } // Operation succeeded. else{ WriteLine("213 " + eArgs.FileSize); } }
/// <summary> /// Raises <b>GetFileSize</b> event. /// </summary> /// <param name="e">Event data.</param> private void OnGetFileSize(FTP_e_GetFileSize e) { if(this.GetFileSize != null){ this.GetFileSize(this,e); } }