Read directory on a FTP-connection

Read directory on a FTP-connection

Postby Marc Vanzegbroeck » Tue Jul 20, 2010 6:48 am

Hello,

Is there a possibility to get all file's available on a FTP-directory (like adir())?
A webapplication creates a file for each order done on the webstore.
Then my program have to copy all files via a FTP-connection from the server and import them.
Then all files should be deleted from the FTP-server.

Thanks,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Read directory on a FTP-connection

Postby Antonio Linares » Tue Jul 20, 2010 7:24 am

Marc,

There is a working example in FWH\samples\FtpDir.prg
regards, saludos

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

Re: Read directory on a FTP-connection

Postby Otto » Tue Jul 20, 2010 7:25 am

********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: Read directory on a FTP-connection

Postby Marc Vanzegbroeck » Tue Jul 20, 2010 8:41 am

Thanks Antonio an Otto,

That's exactly what I need.

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Read directory on a FTP-connection

Postby Marc Vanzegbroeck » Tue Jul 20, 2010 4:41 pm

Hello,

It's working very nice.
The only problem is if no .LOG-file is available
Code: Select all  Expand view
aFiles = oFTP:Directory('*.LOG')
is still returning a len() of 1.
At the end I wanted to show how many files that are tranfered, but if no file is found, I still get 1.

For a workaround, I wanted to test for empty(aFiles[1,1]), but also this is returning NOT EMPTY.
If a do al len(aFiles[1,1])) or a len(alltrim(aFiles[1,1])), I allways get 260...

The workaround now is to test if len(alltrim(aFiles[1,1])) # 260

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Read directory on a FTP-connection

Postby xProgrammer » Thu Jul 22, 2010 12:40 pm

Hi Marc and others

I have found a few issues with the FTP class.

The FTP server always gives a numeric response code which is not always handled appropriately - when you get a remote directory list the response code is added to the end of the list.

There is a problem with the transfer of 0 byte length files (easy enough to program around)

After downloading files remote directory listing stops working. Not sure why. So I build a complete listing of what I need to download before doing any downloading.

Hangs if remote file is unreadable - 500 series response code - comment in source says if 400 or 500 series response code but then only tests for a 400 series response code.

My experiences above just might help someone.

It would be nice if someone could resolve these issues with the current code.

Regards
xProgrammer
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: Read directory on a FTP-connection

Postby PeterHarmes » Mon Jul 26, 2010 8:43 am

I'm also experiencing problems with the directory function returning nothing under certain versions of windows (i think may be other configuration on the pc) the same app works fine on most installations, but returns nothing on others - as soon as i can see what the differences are i will let this forum know.

Regards,

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests