login about faq

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

asked Oct 18 '12 at 07:14

ericW's gravatar image

ericW
1224

edited Oct 18 '12 at 07:16


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 /)

link

answered Oct 18 '12 at 07:22

Gert's gravatar image

Gert ♦
629141824

edited Oct 18 '12 at 07:24

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

link

answered Oct 18 '12 at 07:26

Gert's gravatar image

Gert ♦
629141824

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×201

Asked: Oct 18 '12 at 07:14

Seen: 1,268 times

Last updated: Oct 18 '12 at 07:26

powered by OSQA