Page 1 of 1
Changing directory in tFtp
Posted: Mon Dec 07, 2009 9:28 am
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
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 9:34 am
by PeterHarmes
Solved using Directory() - the path you type in is case sensitive!!
Regards,
Pete
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 10:05 am
by Antonio Linares
Pete,
Thanks for the info
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 11:35 am
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
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 11:50 am
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.
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 11:52 am
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
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 12:03 pm
by PeterHarmes
Antonio,
I get the "oFTP:hFTP is null" message, yet i can access the ftp site through i.e. fine
Regards,
Pete
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 3:18 pm
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