Archived Forum Post

Index of archived forum posts


Current Full Remote Path of File

Feb 27 '13 at 14:33

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


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