How to upload selected files and directories with UltimateSftp
Use the UploadFiles method to easily upload selected files and directories from the local disk to the SFTP server. You just need to provide local path, remote path, files and directories to upload and transfer options, ComponentSoft Ultimate SFTP component will do the rest of hard work for you. Other examples for FTP can also be found at FTP blog.
The following steps show you how to use the UploadFiles method to upload multiple files to the remote server.
C#
// Create a new instance.
Sftp client = new Sftp();
// Connect to the SFTP server.
client.Connect("localhost");
// Authenticate.
client.Authenticate("test", "test");
// ...
// List of files and directories to upload.
string[] files = new string[] { "myfile", "my dir", @"c:\my folder\my dir2" };
// Upload selected files and subdirectories in local folder 'c:\my folder' to the remote dir '/temp'.
client.UploadFiles(@"c:\my folder", files, "/temp", new TransferOptions());
// ...
// Disconnect.
client.Disconnect();
VB.NET
' Create a new instance.
Dim client As New Sftp()
' Connect to the SFTP server.
client.Connect("localhost")
' Authenticate.
client.Authenticate("test", "test")
' ...
' List of files and directories to upload.
Dim files() As String = {"myfile", "my dir", "c:\my folder\my dir2"}
' Upload selected files and subdirectories in local folder 'c:\my folder' to the remote dir '/temp'.
client.UploadFiles("c:\my folder", files, "/temp", New TransferOptions())
' ...
' Disconnect.
client.Disconnect()