Sample code for 30+ languages & platforms
PowerBuilder

FTP Automatic Post-Connect Commands

See more FTP Examples

Demonstrates the AutoFeat, AutoSyst, AutoOptsUtf8, and AutoXcrc properties, which control commands Chilkat issues automatically around connecting and transferring.

Background: Chilkat normally probes and adapts to a server on its own: AutoFeat discovers capabilities with FEAT, AutoSyst learns the OS type to parse legacy listings, and AutoOptsUtf8 enables UTF-8 filenames when the server advertises it. These are on by default and rarely worth changing. AutoXcrc is the exception worth enabling deliberately — it verifies each upload with the server's XCRC checksum, catching corruption automatically where supported.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp

li_Success = 0

loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
    destroy loo_Ftp
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Ftp.Hostname = "ftp.example.com"
loo_Ftp.Username = "myFtpLogin"

//  These auto-* properties control commands Chilkat sends automatically after connecting.  They
//  are on/off by default as noted, and are rarely changed.

//  AutoFeat (default 1): automatically send FEAT to discover server capabilities.
loo_Ftp.AutoFeat = 1

//  AutoSyst (default 1): automatically send SYST after login to learn the server OS type.
loo_Ftp.AutoSyst = 1

//  AutoOptsUtf8 (default 1): send OPTS UTF8 ON when the FEAT response advertises UTF8.
loo_Ftp.AutoOptsUtf8 = 1

//  AutoXcrc (default 0): request an XCRC checksum after each upload and treat a mismatch as
//  a failure, giving automatic post-upload verification where the server supports XCRC.
loo_Ftp.AutoXcrc = 1

//  Normally you would not hard-code the password in source.  You should instead obtain it
//  from an interactive prompt, environment variable, or a secrets vault.
loo_Ftp.Password = "myPassword"

li_Success = loo_Ftp.Connect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

Write-Debug "Connected with the configured automatic features."

li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if



destroy loo_Ftp