Archived Forum Post

Index of archived forum posts

Question:

CreateDir SFTP permission denied

Oct 18 '12 at 07:26

Hi,

My application needs to upload files to a SFTP. I can get connected with a private key. On that server there are 3 folders and I need to create a directory in one of them. The folder I need to create a subfolder in is called "Uploads"

If I connect to the server via FileZilla, I can create the folder, so permissions on that side must be ok. If I try to do it with code I get the following error:

ChilkatLog:
CreateDir:
DllDate: May 21 2011
UnlockPrefix: ERICSSSSH
Username: EV101F7453E58E:EERVAWO
Architecture: Little Endian; 32-bit
Language: .NET 4.0
SshVersion: SSH-2.0-OpenSSH_5.3
SftpVersion: 3
path: uploads\1966
StatusResponse:
  Request: FXP_MKDIR
  StatusCode: 3
  StatusMessage: Permission denied
Failed.

What am I doing wrong here?

My code:

connected = ftp.AuthenticatePk(Username, key)
  success = ftp.InitializeSftp

  If success = True Then
    Try
      success = ftp.CreateDir("uploads\" + sn)
    Catch ex As Exception
    End Try
end if

The success inside the try-catch is false.

rg, Eric


Answer

The above will try to create a "uploads\1996" sub-directory in the home directory of the logged in user ("Username").

If this SFTP server is Windows based, I guess it should work as Windows uses \ as path separator.

More likely this is a Unix server and \ will have no special meaning. Try to use

 success = ftp.CreateDir("uploads/" + sn)
instead.

(change \ to /)


Answer

and as far as I know Chilkat never throws exceptions so there is no need for the try/catch block.