Error uploading file

Advertisement

mwulfe
Joined:
Posts:
3
Location:
Washington, DC area

Error uploading file

I am trying to use VBA in Excel 2010 to upload a file to my SFTP server. When I use WinSCP.exe, the file uploads, but only after a message saying "Upload of the file <FileName> was successful, but error occurred while setting the permissions and/or timestamp. If the problem persists, turn on "ignore permission errors" option."

When I try to upload using VBA, I get error number 2146233088, "Cannot create remote file <filename>". I have tried a filepermissions object and setting Otherwrite, Userwrite, and Groupwrite all to True, but it makes no difference:

   mySession.Open mySessionOptions
    Dim myFilePermissions As New FilePermissions
    myFilePermissions.OtherWrite = True
    myFilePermissions.UserWrite = True
    myFilePermissions.GroupWrite = True
    Dim myTransferOptions As New TransferOptions
    myTransferOptions.TransferMode = TransferMode.TransferMode_Binary
    myTransferOptions.preservetimestamp = False
    myTransferOptions.FilePermissions = myFilePermissions
     
    Dim transferResult As TransferOperationResult
    Set transferResult = mySession.PutFiles("D:\temp\ADBCopy.bat", "/Distribution/FTFZI/PILOT/*.*", False, myTransferOptions)

    ' Throw on any error
    transferResult.Check    

As soon as transferResult.Check runs, it throws the error. What am I doing wrong?

Reply with quote

Advertisement

mwulfe
Joined:
Posts:
3
Location:
Washington, DC area

Re: Error uploading file

Not sure how to do this in VBA. I have tried "= Null" or "= Nothing" and both generated errors. Do you have some sample code for setting that to null?

martin wrote:

Have you tried setting FilePermissions to Null? (it's actually a default value).
Make sure you also keep preservetimestamp = False

See
https://winscp.net/eng/docs/faq_not_owner

Reply with quote

mwulfe
Joined:
Posts:
3
Location:
Washington, DC area

Re: Error uploading file

mwulfe wrote:

Not sure how to do this in VBA. I have tried "= Null" or "= Nothing" and both generated errors. Do you have some sample code for setting that to null?

martin wrote:

Have you tried setting FilePermissions to Null? (it's actually a default value).
Make sure you also keep preservetimestamp = False

See
https://winscp.net/eng/docs/faq_not_owner

The answer was in the rights I was given by the server. When those were changed, I could copy the files.

Martin, thanks for your help!

Reply with quote

Advertisement

You can post new topics in this forum