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. Is there any way to do it? Thank you.
Check the code of WinSCP extension Recursively move files in directory tree to/from SFTP/FTP server while preserving source directory structure.
Some alternatives:
remove
parameter of Session.GetFiles
to true.TransferOperationResult.Transfers
returned by the Session.GetFiles
.Session.RemoveFiles
.A more complicated, but more efficient (if you have a large amount of files) approach would be:
Session.MoveFile
. Despite the name, the method accepts wildcards.Session.GetFiles
with remove
set to true
.