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

ferpega

That was the trick. :-)

Thank you.
martin

Re: RemoveFiles/PutFiles

The argument of Session.RemoveFiles is a wildcard.
https://winscp.net/eng/docs/library_session_removefiles
https://winscp.net/eng/docs/library_wildcard

The [1] in the filename is a set pattern. No file in the remote folder matches that pattern, hence nothing is removed.

As documented, you should escape the filenames using RemotePath.EscapeFileMask to avoid them being interpreted as wildcard/file mask.
https://winscp.net/eng/docs/library_remotepath_escapefilemask
ferpega

Adding a bit more info:

On RemoveFiles Winscp function....
RemovalOperationResult is reporting IsSuccess to true

But there are no items in
* RemovalOperationResult.Removals
nor
* RemovalOperationResult.Failures.

Regards
ferpega

RemoveFiles/PutFiles

Hello

<TL;DR>
RemoveFiles function is reporting it is succed (but the file remains not deleted), but PutFiles is reporting error 11 (File already exists).

It seems WinSCP application is deleting files in a right way.
</TL;DR>

We are using WinSCPNet version: 1.3.7.7441 (last nuget package)

I have this Session and transfer options (on this/failing Dev environment):
new SessionOptions

            {
                Protocol = Protocol.Sftp,
                GiveUpSecurityAndAcceptAnySshHostKey = true,
                HostName = _configurationRepository.FtpServer,
                UserName = _configurationRepository.FtpLogin,
                Password = _configurationRepository.FtpPassword,
            };
result.AddRawSettings("SFTPMaxVersion", _configurationRepository.FtpSftpMaxProcolVersion);


new TransferOptions()

            {
                TransferMode = TransferMode.Binary,
                OverwriteMode = OverwriteMode.Overwrite,
                PreserveTimestamp = false,               
            };
result.ResumeSupport.State = TransferResumeSupportState.Off;



We are deleting every file before Put it on the remote server.
* RemoveFiles function is reporting it is succed
* PutFiles function is reporting error 11.

Here you have a complete session. We have the same problem with files with no special characters, ie: ATT00001.txt

> 2017-05-19 11:48:49.269 Script: rm -- "/Adjuntos/ATC0000000000000000660/DOC353[1].pdf"
. 2017-05-19 11:48:49.270 Listing directory "/Adjuntos/ATC0000000000000000660".
> 2017-05-19 11:48:49.270 Type: SSH_FXP_OPENDIR, Size: 41, Number: 2827
< 2017-05-19 11:48:49.299 Type: SSH_FXP_HANDLE, Size: 17, Number: 2827
> 2017-05-19 11:48:49.300 Type: SSH_FXP_READDIR, Size: 17, Number: 3084
< 2017-05-19 11:48:49.330 Type: SSH_FXP_NAME, Size: 473, Number: 3084
> 2017-05-19 11:48:49.330 Type: SSH_FXP_READDIR, Size: 17, Number: 3340
< 2017-05-19 11:48:49.354 Type: SSH_FXP_STATUS, Size: 29, Number: 3340
< 2017-05-19 11:48:49.354 Status code: 1
> 2017-05-19 11:48:49.354 Type: SSH_FXP_CLOSE, Size: 17, Number: 3588
. 2017-05-19 11:48:49.354 .;d;0;2017-05-19T09:48:46.000Z;3;"root" [0];"root" [0];rw-r--r--;0
. 2017-05-19 11:48:49.355 ..;d;0;2017-05-19T09:48:46.000Z;3;"root" [0];"root" [0];rw-r--r--;0
. 2017-05-19 11:48:49.355 ATC0000000000000000660.pdf;-;28241;2017-05-19T09:48:46.000Z;3;"root" [0];"root" [0];rwxr--r--;0
. 2017-05-19 11:48:49.355 DOC353[1].pdf;-;70084;2017-05-17T11:03:41.000Z;3;"root" [0];"root" [0];rwxr--r--;0
< 2017-05-19 11:48:49.355 Script: No file matching 'DOC353[1].pdf' found.
> 2017-05-19 11:50:09.941 Script: put -delete -nopermissions -nopreservetime -transfer="binary" -resumesupport="off" -- "C:\Users\ferpega\AppData\Local\Temp\ProjectName\20170517_105926\Adjuntos\ATC0000000000000000660\DOC353[1].pdf" "/Adjuntos/ATC0000000000000000660/DOC353[1].pdf"
. 2017-05-19 11:50:09.941 Copying 1 files/directories to remote directory "/Adjuntos/ATC0000000000000000660/"
. 2017-05-19 11:50:09.941 PrTime: No; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: N (102400); CalcS: No; Mask: DOC353[1].pdf
. 2017-05-19 11:50:09.941 TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
. 2017-05-19 11:50:09.941 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2017-05-19 11:50:09.942 File: 'C:\Users\ferpega\AppData\Local\Temp\ProjectName\20170517_105926\Adjuntos\ATC0000000000000000660\DOC353[1].pdf' [2017-05-19T09:46:56.175Z] [70084]
. 2017-05-19 11:50:09.942 Copying "C:\Users\ferpega\AppData\Local\Temp\ProjectName\20170517_105926\Adjuntos\ATC0000000000000000660\DOC353[1].pdf" to remote directory started.
. 2017-05-19 11:50:09.942 Binary transfer mode selected.
. 2017-05-19 11:50:09.942 Opening remote file.
> 2017-05-19 11:50:09.942 Type: SSH_FXP_OPEN, Size: 71, Number: 3843
< 2017-05-19 11:50:09.942 Type: SSH_FXP_STATUS, Size: 17, Number: 3588
. 2017-05-19 11:50:09.942 Discarding reserved response
< 2017-05-19 11:50:09.969 Type: SSH_FXP_STATUS, Size: 38, Number: 3843
< 2017-05-19 11:50:09.969 Status code: 11, Message: 3843, Server: File alaready exists., Language:
> 2017-05-19 11:50:09.970 Type: SSH_FXP_LSTAT, Size: 55, Number: 4103
< 2017-05-19 11:50:09.997 Type: SSH_FXP_ATTRS, Size: 37, Number: 4103
* 2017-05-19 11:50:09.997 (ETerminal) File already exists.
* 2017-05-19 11:50:09.997 Error code: 11
* 2017-05-19 11:50:09.997 Error message from server: File alaready exists.
. 2017-05-19 11:50:09.997 Asking user:
. 2017-05-19 11:50:09.997 Cannot overwrite remote file '/Adjuntos/ATC0000000000000000660/DOC353[1].pdf'.$$
. 2017-05-19 11:50:09.997
. 2017-05-19 11:50:09.997 Press 'Delete' to delete the file and create new one instead of overwriting it.$$ ("File already exists.
. 2017-05-19 11:50:09.997 Error code: 11
. 2017-05-19 11:50:09.997 Error message from server: File alaready exists.")
< 2017-05-19 11:50:09.997 Script: Cannot overwrite remote file '/Adjuntos/ATC0000000000000000660/DOC353[1].pdf'.
< 2017-05-19 11:50:09.997 Script: File already exists.
< 2017-05-19 11:50:09.997 Error code: 11
< 2017-05-19 11:50:09.997 Error message from server: File alaready exists.
* 2017-05-19 11:50:09.998 (EScpSkipFile) Cannot overwrite remote file '/Adjuntos/ATC0000000000000000660/DOC353[1].pdf'.$$
* 2017-05-19 11:50:09.998
* 2017-05-19 11:50:09.998 Press 'Delete' to delete the file and create new one instead of overwriting it.$$
* 2017-05-19 11:50:09.998 File already exists.
* 2017-05-19 11:50:09.998 Error code: 11
* 2017-05-19 11:50:09.998 Error message from server: File alaready exists.
. 2017-05-19 11:50:09.998 Script: Failed


Thanks in advance.