Changing directory in tFtp

Post Reply
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Changing directory in tFtp

Post by PeterHarmes »

Hi,

I'm trying to create a small app that downloads files from an FTP site. My app connects ok to the FTP site, but i want to see what files are in a sub-folder. I've tried to use SetCurrentDirectory() but this doesnt seem to do anything - when i look at the results from :Directory() it always returns what is in the root. Can anyone supply me with an example of using the :directory() routine in a sub-folder?

Many thanks

Pete
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Changing directory in tFtp

Post by PeterHarmes »

Solved using Directory() - the path you type in is case sensitive!!

Regards,

Pete
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Changing directory in tFtp

Post by Antonio Linares »

Pete,

Thanks for the info :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Changing directory in tFtp

Post by PeterHarmes »

I think i might have found a problem with the directory function, if i do this:

aFiles = oFTP:Directory( cDirName + "*.*" )
IF !Empty(aFiles)
FOR nCount := 1 TO Len(aFiles)
IF Left(aFiles[nCount, 1], 1) <> "."
lCopy := .F.
? File( cIwsFolder + "\Upgrade\New\" + aFiles[nCount, 1]) - This always returns .F.

If i do this:

? File( cIwsFolder + "\Upgrade\New\" + Left(aFiles[nCount, 1],12)) - This always returns the correct result

if i do this:

? "-" + Alltrim(aFiles[nCount, 1]) + "-"

the second "-" does not appear

I have got around this by using the left( , 12) example above as i know the length of the filenames

This is using FW09.05

Regards,

Pete
Patrizio
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy
Contact:

Re: Changing directory in tFtp

Post by Patrizio »

FtpFindFirstFile/InternetFindNextFile return the filename filled by a char, i think chr(0).

I use this

Code: Select all

HB_FUNC( CLEARSTRING )                                                                   
{                                                                                         
   hb_retc(hb_parc(1));                                                         
}
 
for clear the filename.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Changing directory in tFtp

Post by Antonio Linares »

Pete,

That would mean that some not valid characters are being placed into the file name. Thats why you can extract a valid portion of it, but if you try to concatenate with another string then it fails.

Could you please test FWH\samples\FtpDir.prg and check if it works fine for you ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Changing directory in tFtp

Post by PeterHarmes »

Antonio,

I get the "oFTP:hFTP is null" message, yet i can access the ftp site through i.e. fine

Regards,

Pete
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Changing directory in tFtp

Post by Antonio Linares »

Pete,

We have just tested it again using Windows 7 and it works fine using FWH 9.11, with both Harbour and xHarbour. But we got a request to allow it from the Windows firewall, that had to be accepted.

Could someone else test FWH\samples\FtpDir.prg and report here how it works ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply