根据从SFTP修改的日期下载文件

编程入门 行业动态 更新时间:2024-10-27 02:19:27
本文介绍了根据从SFTP修改的日期下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有一种方法可以使用Tamir.SharpSsh从SFTP服务器获取基于修改日期的文件?目前,我正在按文件名下载文件,但我的要求是按修改日期"进行.

Is there a way to get the files from SFTP server that should be based on modified date using Tamir.SharpSsh? Currently I am downloading files by file name but my requirement is by Date Modified.

var sftp = new Sftp(Host, UserName, Password); sftp.Connect(); sftp.Get(sourcePath+"/*.*." + name + "*", destinationPath);

推荐答案

SharpSsh不允许这样做.这是一个死项目,请不要使用它.

SharpSsh does not allow that. It's a dead project, do not use it.

无论如何,我看了一下代码,以评估使用 Sftp.GetFileList (因为该库是开源的)来检索文件时间戳的可能性有多困难.

Anyway, I took a look at the code to assess how difficult it would be add possibility to retrieve file timestamp using the Sftp.GetFileList (since the library is open source).

您将必须:

  • 将时间戳字段添加到 ChannelSftp.LsEntry
  • 将解析代码的时间戳从 SSH_FXP_NAME 数据包添加到 ChannelSftp.ls 方法
  • 修改(或添加替代方法) Sftp.GetFileList 不仅返回文件名,还返回时间戳(和其他文件元数据).
  • Add a timestamp field to the ChannelSftp.LsEntry
  • Add parsing out timestamp from the SSH_FXP_NAME packet to the ChannelSftp.ls method
  • Modify (or add an alternative to) the Sftp.GetFileList to return not only file name, but also the timestamp (and other file metadata).

或者,您可以使用 WinSCP .NET程序集.您可以将其 Session.GetFiles 方法与文件掩码.例如.文件掩码 *> 7D 选择上周修改的所有文件.

Alternatively, you can use WinSCP .NET assembly. You can use its Session.GetFiles method with a file mask. E.g. a file mask *>7D selects all files modified in the last week.

(我是WinSCP的作者)

更多推荐

根据从SFTP修改的日期下载文件

本文发布于:2023-11-05 04:21:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559889.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   文件   SFTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!