简体   繁体   English

WinSCP .NET 程序集 - 在 GetFiles 之后删除文件(不是目录)

[英]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:一些替代方案:


A more complicated, but more efficient (if you have a large amount of files) approach would be:一种更复杂但更有效(如果您有大量文件)的方法是:

  • Replicate the directory structure in a remote temporary folder.复制远程临时文件夹中的目录结构。
  • Move all the files there, directory by directory, using Session.MoveFile .使用Session.MoveFile将所有文件逐个目录移动到那里。 Despite the name, the method accepts wildcards.尽管名称如此,但该方法接受通配符。
  • Download and delete the temporary tree at once using Session.GetFiles with remove set to true .使用Session.GetFiles下载并删除临时树, remove设置为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM