如何使用 SharpSSH 库获取 SFTP 上远程文件的 Stream 对象?
如何获取 Stream 对象来读取 SFTP 共享上的文件? 我看到有使用 Sftp 类从 SFTP 下载文件的功能,但我需要一个 Stream 对象才能显示下载进度。
How can I get a Stream object to read the file that is on SFTP share?
I see that there is functionality to download a file from SFTP using Sftp class, but I need a Stream object to be able to show the download progress.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不熟悉 SharpSSH,但是 edtFTPnet/PRO,这是一个支持 SFTP 和 FTPS 的商业 .NET 库使用您可以订阅的 BytesTransferred 事件。
因此,您会定期收到有关已下载或上传的数量的通知,如果您在传输之前获取大小,则可以轻松计算下载进度。
我认为 SharpSSH 有类似的活动,您可以订阅。
I'm not familiar with SharpSSH, but edtFTPnet/PRO, which is a commercial .NET library supporting SFTP and FTPS, uses a BytesTransferred event that you can subscribe to.
So you regularly get notified of how much has been downloaded or uploaded, and if you grab the size before transferring, you can easily then calculate download progress.
I assume SharpSSH has a similar event you can subscribe to.
尝试从 CodePlex 下载 SSH.NET 库
该库有一个下载文件的方法
,但我使用系统方法.Net.WebClient.DownloadData 获取sftp服务器中的文件,该方法返回一个byteArray,可以轻松转换为Stream。
希望这有帮助。
Try to download SSH.NET Library from CodePlex
This library has a method to download a file
But I use the method System.Net.WebClient.DownloadData to get a file in sftp server, this method returns a byteArray, you can easyly convert to Stream.
Hope this helps.