Sample code for 30+ languages & platforms
PowerBuilder

Load Entire File into BinData

Demonstrates how to load an entire file into a BinData object.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Fac
oleobject loo_Bd
integer li_MaxBytesToRead

li_Success = 0

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

li_Success = loo_Fac.OpenForRead("qa_data/pdf/sample.pdf")
if li_Success = 0 then
    Write-Debug loo_Fac.LastErrorText
    destroy loo_Fac
    return
end if

loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")

li_MaxBytesToRead = 99999999
li_Success = loo_Fac.FileReadBd(li_MaxBytesToRead,loo_Bd)
if li_Success = 0 then
    Write-Debug loo_Fac.LastErrorText
    destroy loo_Fac
    destroy loo_Bd
    return
end if

loo_Fac.FileClose()

// The bd object contains the file data...
li_Success = loo_Bd.WriteFile("qa_output/sample.pdf")


destroy loo_Fac
destroy loo_Bd