Topic "Errror trying to upload file using Code"

Author Message
[View user's profile]

Joined: 2016-07-08
Posts: 7
Location: Charleston, SC
I'm trying to upload a file and I'm getting

Error:Cannot overwrite remote file '/studentlists'.$$ <which is the directory on the upload and is empty when testing code
Press 'Delete' to delete the file and create a new one instead of overiting it. $$

I'm using the VBA code...
is there a way to overwite an existing file?
or sync a single file using VB?

blah blah blah for SessionOptions


' Upload files
Dim myTransferOptions As New TransferOptions
myTransferOptions.TransferMode = TransferMode.Binary

Dim transferResult As TransferOperationResult
transferResult = mySession.PutFiles("\\aiken\ProdCognos\ITExtracts\studentlist.csv", "\studentlists", False, myTransferOptions)

' Throw on any error

' Display results
Dim transfer As TransferEventArgs
For Each transfer In transferResult.Transfers
MsgBox("Upload of " & transfer.FileName & " succeeded")
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24759
Location: Prague, Czechia
The correct syntax is:

transferResult = mySession.PutFiles("\\aiken\ProdCognos\ITExtracts\studentlist.csv", "/studentlists/", False, myTransferOptions)

As documented:

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License