Sample code for 30+ languages & platforms
PowerBuilder

Set an FTP Compatibility Option

See more FTP Examples

Demonstrates the Chilkat Ftp2.SetOption method, which enables or disables a named compatibility option. The only argument is the option name; matching is case-insensitive, and prefixing a recognized name with No- disables it.

Background: Real-world FTP servers have quirks, and these named options are targeted workarounds for specific ones — for example Microsoft-TLS-1.2-Workaround addresses a known interoperability issue. Most applications never need any of them; reach for SetOption only when a documented server problem calls for a specific fix, and use the exact recognized name.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp

li_Success = 0

//  Demonstrates the Ftp2.SetOption method, which enables or disables a named compatibility option.
//  The only argument is the option name.  Prefix a name with "No-" to disable it.

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"

//  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

//  Enable a recognized compatibility workaround.  Option-name matching is case-insensitive.
li_Success = loo_Ftp.SetOption("Microsoft-TLS-1.2-Workaround")
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

//  To disable it, prefix the name with "No-":
li_Success = loo_Ftp.SetOption("No-Microsoft-TLS-1.2-Workaround")
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

Write-Debug "Compatibility option toggled."

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



destroy loo_Ftp