(Unicode C) Load Entire File into BinData
Demonstrates how to load an entire file into a BinData object.
#include <C_CkFileAccessW.h>
#include <C_CkBinDataW.h>
void ChilkatSample(void)
{
HCkFileAccessW fac;
BOOL success;
HCkBinDataW bd;
int maxBytesToRead;
fac = CkFileAccessW_Create();
success = CkFileAccessW_OpenForRead(fac,L"qa_data/pdf/sample.pdf");
if (success == FALSE) {
wprintf(L"%s\n",CkFileAccessW_lastErrorText(fac));
CkFileAccessW_Dispose(fac);
return;
}
bd = CkBinDataW_Create();
maxBytesToRead = 99999999;
success = CkFileAccessW_FileReadBd(fac,maxBytesToRead,bd);
if (success == FALSE) {
wprintf(L"%s\n",CkFileAccessW_lastErrorText(fac));
CkFileAccessW_Dispose(fac);
CkBinDataW_Dispose(bd);
return;
}
CkFileAccessW_FileClose(fac);
// The bd object contains the file data...
success = CkBinDataW_WriteFile(bd,L"qa_output/sample.pdf");
CkFileAccessW_Dispose(fac);
CkBinDataW_Dispose(bd);
}
|