FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Read directory on a FTP-connection
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM

Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 06: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 07:24 AM

Marc,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 07:25 AM
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM

Re: Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 08: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
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM

Re: Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 04:41 PM
Hello,

It's working very nice.
The only problem is if no .LOG-file is available
Code (fw): Select all Collapse
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
Posts: 464
Joined: Tue May 16, 2006 07:47 AM

Re: Read directory on a FTP-connection

Posted: 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

Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM

Re: Read directory on a FTP-connection

Posted: Mon Jul 26, 2010 08: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

Continue the discussion