ActionOnExistingFiles.OverwriteAll usage -- am I doing it wrong?

0 votes
asked Jun 23, 2020 by Rob (120 points)

Hi Rebex Team,

I am trying out Rebex.Sftp (2020 R2) version 5.0.7450.0 to upload files. I specified to overwrite files, like this:

sftp.Upload("\\\Temp*.trg", "/home/",

But I am getting this error:

ERROR: SFTP transfer error uploading '\\Temp\GLCHO0000C202006239381.trg' to '/home/GLCHO0000C202006239381.trg' - Rebex.Net.SftpException: File with the same name already exists ('/home/GLCHO0000C202006239381.trg').

Am I missing something? I can post more of my code if needed.

Thank you,

Applies to: Rebex SFTP
commented Jun 24, 2020 by Lukas Matyska (58,750 points)
I have noticed one weird thing.
You wrote that you are calling "\\\Temp*.trg" which was resolved to "\\Temp\GLCHO0000C202006239381.trg".
This should not be possible.
The "Temp*.trg" can be expanded to e.g. "Temp-2020-01-01.trg" but it should not be expanded to "Temp\file.trg".

The log file should tell us more.
commented Jun 24, 2020 by Rob (120 points)
Hi Lukas.  Good catch, but I am not worried about this one.  The actual paths in my log are quite a bit longer; I just shortened them to "Temp" for simplicity in the post.  I should have written:

sftp.Upload("\\\Temp\*.trg", ...

Thank you,
commented Jun 25, 2020 by Lukas Matyska (58,750 points)
Oh, OK.
It makes sense now. I though it was a real path except the "" part.

1 Answer

0 votes
answered Jun 24, 2020 by Lukas Matyska (58,750 points)
edited Jun 25, 2020 by Lukas Matyska

It seems that you are doing everything correctly. The file should be overwritten.

Can you please create communication log in Debug level and post it here or send it to for analysis?

It can be created like this:

var sftp = new Sftp();
sftp.LogWriter = new Rebex.FileLogWriter(@"c:\data\log.txt", Rebex.LogLevel.Debug);

The provided log showed, that there were two calls of the Upload method. The second call used the default ActionOnExistingFiles = ThrowException, which caused the reported error.

commented Jun 24, 2020 by Rob (120 points)
Hi Lukas,

Thank you very much for the great info, and for the link to the Logging article.

I have enabled logging in my application and will deploy it to test the overwrite error.