Sample code for 30+ languages & platforms
B4X

Load Entire File into BinData

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

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

Dim fac As ChilkatFileAccess
fac.Initialize

success = fac.OpenForRead("qa_data/pdf/sample.pdf")
If success = False Then
    Log(fac.LastErrorText)
    Return
End If


Dim bd As ChilkatBinData
bd.Initialize
Dim maxBytesToRead As Int = 99999999
success = fac.FileReadBd(maxBytesToRead, bd)
If success = False Then
    Log(fac.LastErrorText)
    Return
End If


fac.FileClose

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