Visual FoxPro
Visual FoxPro
FTP Download File to a Stream
Demonstrates how to FTP download a file to a Chilkat stream.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loFtp
LOCAL loStreamObj
lnSuccess = 0
* This example assumes the Chilkat FTP2 API to have been previously unlocked.
* See FTP2 Unlock Sample for sample code.
loFtp = CreateObject('Chilkat.Ftp2')
loFtp.Hostname = "my-ftp-server.com"
loFtp.Port = 21
loFtp.Username = "mFtpLogin"
loFtp.Password = "myFtpPassword"
loFtp.AuthTls = 1
loFtp.Passive = 1
* Connect and login to the FTP server using TLS.
lnSuccess = loFtp.Connect()
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Move to the sub-directory (from the FTP user's home directory) where the file is located.
lnSuccess = loFtp.ChangeRemoteDir("temp")
IF (lnSuccess = 0) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Stream to this local file:
loStreamObj = CreateObject('Chilkat.Stream')
loStreamObj.SinkFile = "c:/temp/qa_output/penguins2.jpg"
lnSuccess = loFtp.GetFileToStream("penguins2.jpg",loStreamObj)
IF (lnSuccess = 0) THEN
? loFtp.LastErrorText
RELEASE loFtp
RELEASE loStreamObj
CANCEL
ENDIF
loFtp.Disconnect()
? "Success."
RELEASE loFtp
RELEASE loStreamObj