Topic "Set transferOptions.FilePermissions via VB (Express)"

Author Message
[View user's profile]

Joined: 2013-10-30
Posts: 3
As the subject says, I want to change the filepermissions - for the files to be transferred - via a script, and I always receive an error when I try to set the parameter.

The error: Object reference not set to an instance of an object.

Is this a bug, or what am I missing?

Part of the script (which works, as long as don't use the line transferOptions.FilePermissions.GroupWrite = True
Using session As Session = New Session
 ' Connect

 ' Upload files
 Dim transferOptions As New TransferOptions
 transferOptions.TransferMode = TransferMode.Ascii
 '******** The line below generates an error ***********
 transferOptions.FilePermissions.GroupWrite = True

 Dim transferResult As TransferOperationResult
 transferResult = session.PutFiles(path_orig, strUploadDirRemote, False, transferOptions)

 ' Throw on any error

 ' Print results
 Dim transfer As TransferEventArgs
 For Each transfer In transferResult.Transfers
   Me.RTbox.AppendText("Upload of '" & transfer.FileName & "' succeeded" & vbCrLf)
End Using

There is also a try/catch, but this isn't given in in the code, I also updated to the latest version (5.1.7), but it doesn't make a difference
[View user's profile]

Joined: 2013-10-30
Posts: 3
I found the solution in another post in the ".NET & COM Library" (which didn't show up with the search, or better, didn't notice it).

The filepermissions seems to be set first, befor assigning..

So i.s.o.
transferOptions.FilePermissions.GroupWrite = True

I needed
Dim fp As New FilePermissions
fp.GroupWrite = True
transferOptions.FilePermissions = fp

Well, actually, as the new Filepermissions is empty, I actually used "fp.Numeric = 438 'oct 666"

You can post new topics in this forum


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