Changing directory in tFtp

Changing directory in tFtp

Postby PeterHarmes » Mon Dec 07, 2009 9: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
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Changing directory in tFtp

Postby PeterHarmes » Mon Dec 07, 2009 9:34 am

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

Regards,

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

Re: Changing directory in tFtp

Postby Antonio Linares » Mon Dec 07, 2009 10:05 am

Pete,

Thanks for the info :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Changing directory in tFtp

Postby PeterHarmes » 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 + "\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
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Changing directory in tFtp

Postby Patrizio » Mon Dec 07, 2009 11:50 am

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

I use this

Code: Select all  Expand view
HB_FUNC( CLEARSTRING )                                                                  
{                                                                                        
   hb_retc(hb_parc(1));                                                        
}
 


for clear the filename.
Patrizio
 
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy

Re: Changing directory in tFtp

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Changing directory in tFtp

Postby PeterHarmes » 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
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Changing directory in tFtp

Postby Antonio Linares » Mon Dec 07, 2009 3: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 49 guests