Downloading an FTP File
Downloading a file via FTP is as simple as using the wwFTP class and calling the FTPGetFile method of the class. The class supports wildcard filenames so you can download more than one file in a single pass.
DO wwFtp && Load Library loFtp=CREATEOBJECT("wwFTP") IF loFtp.[FTPGetFile](vfps://Topic/wwftp%3A%3AFTPGetFile%20)("ftp.west-wind.com","wwxml.zip","c:\temp\wwxml.zip") # 0 ? loFtp.cErrorMsg ENDIF ** Or you can use object syntax: loFtp.cFTPServer="ftp.west-wind.com" loFtp.cFTPSource="/wwxml.zip" loFtp.cFTPTarget="c:\temp\wwxml.zip" IF loFtp.FTPGetFile() # 0 ? loFtp.cErrorMsg ENDIF
The above method is the easiest to use, but it connects and disconnects for each file. If you need to download more than one file, you can use FTPGetFileEx instead:
loFtp=CREATEOBJECT("wwFTP") loFtp.FTPConnect("ftp.west-wind.com") loFtp.FTPGetFileEx("/downloads/pkzip.exe","c:\temp\pkzip.exe") loFtp.FTPGetFileEx("/downloads/pkunzip.exe","c:\temp\pkunzip.exe") loFtp.FTPClose()
This is more efficient as no reconnecting occurs. The FTPGetFileEx method also supports a message event that you can capture to report download status, which the plain FTPGetFile does not support.
Comment or report problem with topic