0 votes
by (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("\\mydomain.com\Temp*.trg", "/home/",

But I am getting this error:

ERROR: SFTP transfer error uploading '\mydomain.com\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
by (67.2k points)
I have noticed one weird thing.
You wrote that you are calling "\\mydomain.com\Temp*.trg" which was resolved to "\mydomain.com\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.
by (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("\\mydomain.com\Temp\*.trg", ...

Thank you,
by (67.2k points)
Oh, OK.
It makes sense now. I though it was a real path except the "mydomain.com" part.

1 Answer

0 votes
by (67.2k points)
edited by

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 support@rebex.net 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.

by (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.