Skip to content

Add support for a Task based async API #153

Closed
@TrevorPilley

Description

@TrevorPilley

It'll make the library much easier to use with async/await and fit the modern .NET async friendly way of working.

I'd suggest at minimum the following methods:

  • public Task<Stream> DownloadFileAsync(string path)
  • public Task<IEnumerable<SftpFile>> ListDirectoryAsync(string path)
  • public Task UploadFileAsync(string path, Stream stream, bool overwrite = false)

I've managed to wrap the old IAsyncResult style API you already have for DownloadFile as follows:

await Task.Factory.FromAsync(this.sftpClient.BeginDownloadFile(remoteUri, stream), this.sftpClient.EndDownloadFile) but I'm struggling to figure out the way to do the same for ListDirectory...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions