DataFlex
DataFlex
Restart/Resume FTP Download
See more FTP Examples
Resume downloading a file from an FTP server.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sLocalFilename
String sRemoteFilename
String sTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "login"
Set ComPassword Of hoFtp To "password"
// Connect and login to the FTP server.
Get ComConnect Of hoFtp To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// Change to the remote directory where the file is located.
// This step is only necessary if the file is not in the root directory
// for the FTP account.
Get ComChangeRemoteDir Of hoFtp "temp" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// To resume a download, it is assumed that the partial file
// is already present on the local filesystem.
// You only need to set the RestartNext property to resume
// the download. The Chilkat FTP component sets the resume
// point by getting the existing size of the target (local) file.
Set ComRestartNext Of hoFtp To True
Move "big.zip" To sLocalFilename
Move "big.zip" To sRemoteFilename
// Resume downloading...
Get ComGetFile Of hoFtp sRemoteFilename sLocalFilename To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComDisconnect Of hoFtp To iSuccess
Showln "File Downloaded!"
End_Procedure