Sample code for 30+ languages & platforms
Unicode C++

Load Entire File into BinData

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

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkFileAccessW.h>
#include <CkBinDataW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkFileAccessW fac;

    success = fac.OpenForRead(L"qa_data/pdf/sample.pdf");
    if (success == false) {
        wprintf(L"%s\n",fac.lastErrorText());
        return;
    }

    CkBinDataW bd;
    int maxBytesToRead = 99999999;
    success = fac.FileReadBd(maxBytesToRead,bd);
    if (success == false) {
        wprintf(L"%s\n",fac.lastErrorText());
        return;
    }

    fac.FileClose();

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