login about faq

Is there a way to get the current full remote path of file in FTP2 and SFTP?

asked Feb 27 '13 at 09:32

lavanyadeepak's gravatar image


are you asking how to determine the remote path of a file for which you have knowledge of the local path? or a file you are currently manipulating remotely?

(Feb 27 '13 at 11:14) blaze4218

I know my local path. I want to know the full path of the file which I am downloading like

/home/lavanyadeepak/ftpserver/path/file.txt (for both FTP2 and SFTP)

(Feb 27 '13 at 12:11) lavanyadeepak

I am at a loss for how you can be downloading a file that you don't already know the remote path for. The only way I can think of would be that you are using either the DownloadTree method, or the MGetFiles method, or the SyncLocalTree method. All of which appear to be synchronous calls, so unless your language supports callback events- you can't do much in between file downloads.

All other download methods appear to require the input of the path in order to process the download. To accomplish a multi-download equal to one of the above commands asynchronously, you could use GetCurrentRemoteDir and GetTextDirListing to decide which files need to be downloaded, and download them programmatically. The latter of the two can be parsed and each listing passed to a download method, and combining of the first with the listing tells you the path...

Conversely, if you are in a directory, and are just downloading a file (that you already know the name of) you can combine the filename with GetCurrentRemoteDir to get the full path:

Remote_File = "file.txt"                //or however else you have determined this
Remote_Dir_Path = obj_FTP2.GetCurrentRemoteDir()
Full_Remote_Path = Remote_Dir_Path + Remote_File

As you can see: I had to make a lot of assumptions here... If this isn't the answer you were looking for, maybe you could provide some more information about what you're doing; how you're doing it; what language you're doing it in; and what you've already tried.

I hope this was helpful


answered Feb 27 '13 at 14:33

blaze4218's gravatar image


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: Feb 27 '13 at 09:32

Seen: 3,466 times

Last updated: Feb 27 '13 at 14:33

powered by OSQA