 Archived Forum Post
 Archived Forum PostQuestion:
Hi Chilkat,
I am uploading files, then setting trying to set permissions to the file, but getting an error.
Code: 
        success = sftp.SetPermissions("foldername/test1.txt", False, 777)
        If (success <> True) Then
            Console.WriteLine(sftp.LastErrorText)
            sb_LogDebug(sftp.LastErrorText)
            Exit Sub
        End If
Using Chilkat 9.5.0.51
The details of the log are below:
ChilkatLog:
  SetPermissions:
    DllDate: Jun 23 2015
    ChilkatVersion: 9.5.0.51
    UnlockPrefix: CRMSOL.CB10716
    Username: CRMNB5:tim
    Architecture: Little Endian; 64-bit
    Language: .NET 4.5 / x64
    VerboseLogging: 0
    SshVersion: SSH-2.0-OpenSSH_5.9
    SftpVersion: 3
    filename: fujitsu/test1.dat
    isHandle: 0
    octalPermissions: 1411
    FileAttr_v3:
      permissionsHex: 0x309
    --FileAttr_v3
    StatusResponseFromServer:
      Request: SetPermissions
      InformationReceivedFromServer:
        StatusCode: 4
        StatusMessage: Failure
      --InformationReceivedFromServer
    --StatusResponseFromServer
    Failed.
  --SetPermissions
--ChilkatLog
                            I found this reference about SFTP status codes on the web: https://winscp.net/eng/docs/sftp_codes
"Unfortunately, OpenSSH SFTP server uses always description “Failure”. Is such case, there is unfortunately no way to tell a reason of the failure."
I suspect the error is from an invalid permissions value (i.e. the bit flags may make no sense). You're passing decimal 777 in this code:
Code: 
        success = sftp.SetPermissions("foldername/test1.txt", False, 777)
        If (success <> True) Then
            Console.WriteLine(sftp.LastErrorText)
            sb_LogDebug(sftp.LastErrorText)
            Exit Sub
        End If
The correction is to specify the permissions using the octal literal representation in the programming language you are using. For example, it might be this:
Code: 
        success = sftp.SetPermissions("foldername/test1.txt", False, 0777)
        If (success <> True) Then
            Console.WriteLine(sftp.LastErrorText)
            sb_LogDebug(sftp.LastErrorText)
            Exit Sub
        End If