SftpClient FileUpload asynchronous version

Oct 28, 2014 at 11:47 AM
There is no direct asynchronous file upload method. They may have support in future. In the meantime you may use this extension method. It worked for me. :)
public static class SftpClientExtension
{
public static async Task UploadFileAsync(this SftpClient client, Stream input, string path, Action<ulong> uploadCallback = null)
    {
        await Task.Factory.FromAsync(client.BeginUploadFile(input, path, null, null, uploadCallback), client.EndUploadFile);
    }
}