FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Changing directory in tFtp
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Changing directory in tFtp
Posted: Mon Dec 07, 2009 09:28 AM

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

Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 09:34 AM

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

Regards,

Pete

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 10:05 AM

Pete,

Thanks for the info :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 11:35 AM

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 + &quot;\Upgrade\New\&quot; + Left(aFiles[nCount, 1],12)) - This always returns the correct result

if i do this:

        ? &quot;-&quot; + Alltrim(aFiles[nCount, 1]) + &quot;-&quot;

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

Posts: 90
Joined: Wed Nov 07, 2007 08:56 AM
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 11:50 AM
FtpFindFirstFile/InternetFindNextFile return the filename filled by a char, i think chr(0).

I use this

Code (fw): Select all Collapse
HB_FUNC( CLEARSTRING )                                                                   
{                                                                                         
   hb_retc(hb_parc(1));                                                         
}


for clear the filename.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 11:52 AM

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
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 12:03 PM

Antonio,

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

Regards,

Pete

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Changing directory in tFtp
Posted: Mon Dec 07, 2009 03:18 PM

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

Continue the discussion