GetFiles with Remove set to true deletes empty directory

Advertisement

david.vangeest@...
Guest

GetFiles with Remove set to true deletes empty directory

When executing GetFiles on a server with an empty directory, WinSCP is sending a command to delete the actual directory the files are stored in. Here's how I have the command setup:
session.GetFiles("/", _mySettings.DownloadDirectory, true, transferOptions)
This is not the behavior I expected.

Reply with quote

Advertisement

wrusselmslc
Joined:
Posts:
1

Re: GetFiles with Remove set to true deletes empty directory - Me Too

Don't have the same syntax error as OP:
using Session session = new Session();
session.Open(sessionOptions);
 
var options = new TransferOptions();
options.OverwriteMode = OverwriteMode.Overwrite;
options.PreserveTimestamp = true;
options.TransferMode = TransferMode.Binary;
options.FileMask = "CM_*_*.ager.txt";
 
result = session.GetFiles("/test/from/", @"c:\temp\", true, options);
Running this code will pull all files that match the mask, but if there are no more files in the FTP directory, the from directory is deleted as well. If there are no files in the from directory at all, it will still delete the from directory.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: GetFiles with Remove set to true deletes empty directory - Me Too

You DO have the same syntax error as OP.
It should be:
result = session.GetFiles("/test/from/*", @"c:\temp\", true, options);

Or simply:
result = session.GetFiles("/test/from/CM_*_*.ager.txt", @"c:\temp\", true);
(no TransferOptions)

Reply with quote

Advertisement

You can post new topics in this forum