SendCommand on SFTP


We have a site that just switched to SFTP. It has a custom integration which used SendCommand.  This method does not exist on the SFTP component. How can I issue commands on SFTP?

edited 12/3/2017 5:07:02 AM
asked 3/29/2017 11:01:52 PM
add a comment

1 Answers



Is this what you are looking for?

using System;

using System.Text;
using ComponentPro.IO;
using ComponentPro.Net;


// Create a new Sftp instance.
Sftp client = new Sftp();

// Connect to the SFTP server.

SecureShellChannel sshChannel = client.Connection.OpenSession();

// Authenticate.
client.Authenticate(userName, password);

// List directory '/usr/share/doc'
sshChannel.RequestExec("ls /usr/share/doc");

// Process the command response
StringBuilder response = new StringBuilder();
byte[] buffer = new byte[4096];
while (true)
    int n = sshChannel.Receive(buffer, 0, buffer.Length);
    if (n == 0)

    response.Append(Encoding.Default.GetString(buffer, 0, n));

// Show the directory content
Console.WriteLine("Directory content: " + response.ToString());

// Disconnect. 


answered 11/16/2017 12:41:37 AM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged ftp sftp or ask your own question.