login about faq

I am using a 30 day trial to test the SFTP Library. I can upload a local file to a SFTP site but it always is written to the root "." Directory. I have tried to use absPath = sftp.RealPath(".", "/dest")

But file is still uploaded to the "." Directory.

How do I change the directory?

asked Jun 21 '12 at 16:48

chilkat's gravatar image

chilkat ♦♦

SFTP is Secure File Transfer over SSH. It is not the FTP protocol. There is no similarity or relationship between FTP and SFTP. Therefore, concepts such as “current remote directory” that exist in FTP do not exist with SFTP. With the SFTP protocol, the current directory will always be the home directory of the user account used during SSH/SFTP authentication. You may pass relative or absolute directory/file paths. A relative path is always relative to the home directory of the SSH user account. See this blog post for more details about absolute paths: SFTP Absolute Directory Paths

Further clarification: “SFTP” is the Secure File Transfer Protocol over SSH. It is a protocol unrelated to the FTP protocol. The Chilkat SSH / SFTP component is used for “SFTP”. SFTP is achieved by connecting to an SSH server at port 22.

On the other hand, the Chilkat FTP2 components is for FTP. FTP servers listen at port 21 (non-SSL/TLS) and port 990 (SSL). FTP over SSL (i.e. port 990) is called “FTPS”. (not SFTP)


answered Jun 21 '12 at 16:50

chilkat's gravatar image

chilkat ♦♦

You don't "change directories". If you are calling the UploadFileByName method, then the remoteFilePath argument would be something like "./subdir1/subdir2/myFile.dat" and the localFilePath would be the path (relative or absolute) of the file in the local filesystem.

For any method having a remote path argument, you would specify either the path relative to the HOME directory of the SSH user account, or the absolute path from the root of the remote filesystem. I would always recommend using the relative path from the HOME directory.


answered Jul 09 '12 at 22:58

chilkat's gravatar image

chilkat ♦♦

This does not work when you do not know whether you are connecting to a Windows or Linux server who use different slashes in the paths.

Uploading to /home/dir/myfile or homedirmyfile are not compatible.


answered Dec 03 '14 at 13:46

SwankPad's gravatar image


SFTP servers will always use forward slashes, and would likely automatically convert backslashes to forward slashes. Chilkat converts backslashes to forward slashes for the actual SFTP protocol message sent to the SFTP server.

(Dec 03 '14 at 13:52) chilkat ♦♦

It is not working. We upload using: FTPDirectory = "batches" lsFileName is the full path to the local file "D:DIRDIRP504_PIStatement.txt" lsOnlyFileName is the file name without the path, here it is "P504_PIStatement.txt"

lxHandle = pxSFTP.OpenFile(Destination.FTPDirectory & "" & lsOnlyFileName, "writeOnly", "createNew") lbSuccess = pxSFTP.UploadFile(lxHandle, lsFileName)

And on the Linux SFTP server they are getting this:



answered Dec 03 '14 at 14:05

SwankPad's gravatar image


The forum is not a free support line. If you are under the non-expired support of a purchase license, you may send email to support@chilkatsoft.com.

(Dec 03 '14 at 15:01) chilkat ♦♦
Your answer
toggle preview

Follow this question

By Email:

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



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



Asked: Jun 21 '12 at 16:48

Seen: 12,558 times

Last updated: Dec 03 '14 at 15:01

powered by OSQA