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.

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

martin

Re: Cannot overwrite remote file - while doing $session.PutFiles

Please post some code. Also attach a full session log file showing the problem (using the latest version of WinSCP). Do not remove the paths from the log. Or at least replace them meaningfully with some example paths.

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.
kiranvm327

Cannot overwrite remote file - while doing $session.PutFiles

Hi,

I am getting "Output: [Cannot overwrite remote file " message while writing files to sftp server using "$session.PutFiles"
I am uploading the files using WinSCP .NET assembly.
I noticed that file upload is failing when I create a directory using "$session.CreateDirectory($remotePath)" and then load data to this directory using "$session.PutFiles".
Directory path is getting created, but files are not getting uploaded.

If I try uploading files to other directory path which already exists, then it is uploading. Only for new directory created, files are not uploading.


Error message in log file:
Output: [winscp> put -delete -nopermissions -preservetime -transfer="binary" -- "<Source local file path>" "<destination vm file path>"]

Output: [Cannot overwrite remote file '<destination vm file path>'.]
ExeSessionProcess.ProcessEvent entering
Scheduling output: [General failure (server should provide error description).]
Scheduling output: [Error code: 4]
Scheduling output: [Error message from server: Failure]
Scheduling output: [Common reasons for the Error code 4 are:]
Scheduling output: [- Renaming a file to a name of already existing file.]
Scheduling output: [- Creating a directory that already exists.]
Scheduling output: [- Moving a remote file to a different filesystem (HDD).]
Scheduling output: [- Uploading a file to a full filesystem (HDD).]
Scheduling output: [- Exceeding a user disk quota.]