0 votes
by (8.4k points)

How can I execute a specific command on a FTP server with Rebex components?

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (58.9k points)

To send a command to the FTP server from Rebex ftp client, use methods SendCommand(string command) and ReadResponse() as in the following example:

//conect and login to the ftp server
Ftp ftp = new Ftp();
ftp.Connect("hostname", "port");
ftp.Login("username", "password");

//send the command, the capitalization does not matter
string command = "...";

//read the response from the server
FtpResponse response = ftp.ReadResponse();

// if the command was not succesfully understood or executed, throw an exception
if (response.Group != 2) 
  throw new FtpException(response);

//response.Description contains a short description of what happened

//If you want to write the entire response of the server, do:

Other method which can be used to send SITE commands is described at this forum post.