(DataFlex) Load Entire File into BinData
Demonstrates how to load an entire file into a BinData object.
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoFac
Boolean iSuccess
Variant vBd
Handle hoBd
Integer iMaxBytesToRead
String sTemp1
Get Create (RefClass(cComCkFileAccess)) To hoFac
If (Not(IsComObjectCreated(hoFac))) Begin
Send CreateComObject of hoFac
End
Get ComOpenForRead Of hoFac "qa_data/pdf/sample.pdf" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFac To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatBinData)) To hoBd
If (Not(IsComObjectCreated(hoBd))) Begin
Send CreateComObject of hoBd
End
Move 99999999 To iMaxBytesToRead
Get pvComObject of hoBd to vBd
Get ComFileReadBd Of hoFac iMaxBytesToRead vBd To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFac To sTemp1
Showln sTemp1
Procedure_Return
End
Send ComFileClose To hoFac
// The bd object contains the file data...
Get ComWriteFile Of hoBd "qa_output/sample.pdf" To iSuccess
End_Procedure
|