Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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)


Topic review


I did not capture that when the issue occurred. I will let you know when it happens again. The issue is not repeatable when it occurs. Re-running the script will run with success.

Re: Attaching the session log

Thanks. What file remained in the folder, where WinSCP fails?

Attaching the session log

We were able to replicate the error. I'm attaching a scrubbed log file.

Re: Session.SynchronizeDirectories error

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Session.SynchronizeDirectories error

I am using the SynchronizeDirectories in PowerShell, through the .Net assembly to clear a remote directory. Sometimes, the SynchronizeDirectories function will try to delete a folder that is not empty.

I am using SynchronizeDirectories likes this:

$synchronizationResult = $session.SynchronizeDirectories(


$transferOptions = New-Object WinSCP.TransferOptions
    $transferOptions.PreserveTimestamp = $True

this will sometimes result in this error:

##[error]Exception calling "Check" with "0" argument(s): "Error deleting file
The directory is not empty.
Error code: 18
Error message from server (en): The directory is not empty. "

I have noticed this only happens with a folder that has an underscore in the name. The error occurrs when calling $synchronizationResult.Check().