Page 1 of 1

Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 6:48 am
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

Re: Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 7:24 am
by Antonio Linares
Marc,

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

Re: Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 7:25 am
by Otto
Please see 2) FW for PC
http://forums.fivetechsupport.com/viewt ... ftp#p80987

Best regards,
Otto

Re: Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 8:41 am
by Marc Vanzegbroeck
Thanks Antonio an Otto,

That's exactly what I need.

Regards,
Marc

Re: Read directory on a FTP-connection

Posted: Tue Jul 20, 2010 4:41 pm
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

Re: Read directory on a FTP-connection

Posted: Thu Jul 22, 2010 12:40 pm
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

Re: Read directory on a FTP-connection

Posted: Mon Jul 26, 2010 8:43 am
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