[英]WinSCP .NET assembly - Remove files (not directories) after GetFiles
I'm trying to download files from a big tree of recursive directories, and I want the downloaded files to be removed after download.我正在尝试从递归目录的大树中下载文件,并且我希望在下载后删除下载的文件。 When I put true
in remove
parameter of GetFiles
, it removes all the directories, but I want it to remove only the files and leave the directories empty.当我在GetFiles
remove
参数中设置true
时,它会删除所有目录,但我希望它只删除文件并将目录留空。 Is there any way to do it?有什么办法吗? Thank you.谢谢你。
Use WinSCP extension Recursively move files in directory tree to/from SFTP/FTP server while preserving source directory structure .使用 WinSCP 扩展递归地将目录树中的文件移入/移出 SFTP/FTP 服务器,同时保留源目录结构。
Some alternatives:一些替代方案:
remove
parameter of Session.GetFiles
to true.定期下载 = 不要将Session.GetFiles
remove
参数设置为 true。TransferOperationResult.Transfers
returned by the Session.GetFiles
.迭代Session.GetFiles
返回的TransferOperationResult.Transfers
。Session.RemoveFiles
.对于文件的每次成功下载,调用Session.RemoveFiles
。A more complicated, but more efficient (if you have a large amount of files) approach would be:一种更复杂但更有效(如果您有大量文件)的方法是:
Session.MoveFile
.使用Session.MoveFile
将所有文件逐个目录移动到那里。 Despite the name, the method accepts wildcards.尽管名称如此,但该方法接受通配符。Session.GetFiles
with remove
set to true
.使用Session.GetFiles
下载并删除临时树, remove
设置为true
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.