Using the Sftp.Queue method to do multiple simultaneous SFTP transfers

The IPWorks SSH SFTP component's Queue method allows you to queue multiple file transfers and then execute them simultaneously by calling either the Download or Upload method.

You can limit the number of active simultaneous transfers by changing the value of the SimultaneousTransferLimit configuration option. The default value is 5.

Below is a snippet of code that shows the basic logic required to implement this sort of functionality. Note that the code below does not include implementations of any event handlers, some of which are required (such as the SSHServerAuthentication event).

C# Sftp sftp = new Sftp(); sftp.SSHUser = "test"; sftp.SSHPassword = "test"; sftp.SSHLogon("host", 22); for (int i = 0; i < 10; i++) { // Queue files by setting their local and remote paths. sftp.QueueFile("C:/localpath/file" + i + ".txt", "/remotepath/file" + i + ".txt"); } // You can limit the number of simultaneous transfers active regardless of the // number of queued files. The default is 5. sftp.Config("SimultaneousTransferLimit=5"); // Nothing will be downloaded or uploaded until either the Download() or Upload() // methods are called, at which point the whole queue will be processed. sftp.Download(); // You can call ResetQueue() to clear the queue. This won't affect current transfers. sftp.ResetQueue();

For more details about how to use the Sftp.Queue method, check out its documentation.

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at