Sample code for 30+ languages & platforms
C++

Load Entire File into BinData

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

Chilkat C++ Downloads

C++
#include <CkFileAccess.h>
#include <CkBinData.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkFileAccess fac;

    success = fac.OpenForRead("qa_data/pdf/sample.pdf");
    if (success == false) {
        std::cout << fac.lastErrorText() << "\r\n";
        return;
    }

    CkBinData bd;
    int maxBytesToRead = 99999999;
    success = fac.FileReadBd(maxBytesToRead,bd);
    if (success == false) {
        std::cout << fac.lastErrorText() << "\r\n";
        return;
    }

    fac.FileClose();

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