Read directory on a FTP-connection

Post Reply
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Read directory on a FTP-connection

Post by Marc Vanzegbroeck »

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

Re: Read directory on a FTP-connection

Post by Antonio Linares »

Marc,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Read directory on a FTP-connection

Post by Otto »

Please see 2) FW for PC
http://forums.fivetechsupport.com/viewt ... ftp#p80987

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Read directory on a FTP-connection

Post by Marc Vanzegbroeck »

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: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Read directory on a FTP-connection

Post by Marc Vanzegbroeck »

Hello,

It's working very nice.
The only problem is if no .LOG-file is available

Code: Select all

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
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: Read directory on a FTP-connection

Post by xProgrammer »

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

Re: Read directory on a FTP-connection

Post by PeterHarmes »

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
Post Reply