Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

ss_doug

Hi,

Thanks for the quick response and move/rename suggestion.

Doug
martin

Re: Question about remove parameter in GetFiles

The file is deleted immediately after the download finishes. Though, it is not an atomic operation.

If you need to make it atomic, you need to rename/move the remote file to unique name before download. See Session.MoveFile:
https://winscp.net/eng/docs/library_session_movefile
ss_doug

Question about remove parameter in GetFiles

Hello,

I have a situation where my application will be downloading files from an sftp server throughout the day, and I've been asked to delete the files after they are downloaded.

The source files on the sftp server can come in at any time, and may or may not have the same filenames as those which have already been downloaded.

My problem scenario is this:
A bunch of files, including "A.txt" are placed in a directory on the sftp server.
My app calls GetFiles to get the contents of the entire directory. The remove parameter is set to True.
At some point during this process - after A.txt is downloaded - a new copy A.txt is placed on the server.
I need to know if the new copy of A.txt will get deleted by the GetFiles method.

Does GetFiles treat the download-then-delete routine as a single, atomic, operation, or is there enough of a time lag between get and remove to cause problems in my scenario?

thanks,
Doug