Downloading and returning a non blocking stream of data using SSH.Net

我的梦境 提交于 2019-12-06 02:24:35

This is old question, but I had similar issue. If you want to get the stream directly you can write to MemoryStream.

SftpClient _sftpClient;
_sftpClient = new SftpClient("sftp.server.domain", "MyLoginHere", "MyPasswordHere");
Stream fileBody = new MemoryStream();
_sftpClient.DownloadFile(ftpFile.FullName, fileBody);
fileBody.Position = 0; //dont forget to set the stream position back to beginning

If you want to download file, you can make it in separate thread or as asynchronous call and then call the delegate:

_sftpClient.DownloadFile(ftpFile.FullName, fileBody, YourActionDelegateHere);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!