Xceed Binary Encoding Library Documentation
ReadFile method
Xceed Binary Encoding control reference > Methods > ReadFile method

Description

The ReadFile method can encode and decode data from a file to memory, as well as simply read file data to memory without processing it.

Parameters
 

Parameter Description
sSourceFilename  The path and filename of the file to read and process data from.
lSourceOffset  The starting offset in the file to begin processing data from. Specify 0 to begin processing data from the beginning of the file.
lSourceSize  The amount of data to process. Specify 0 to process data from the starting offset until the end of the file.
eAction  The type of processing that should be performed. Specify bfpEncode to encode data before writing it to memory. Specify bfpDecode to decode data before writing it to memory.
bEndOfData  Determines whether or not the source data to read is the final (or the only) portion of data to process. Specify True if the source data should be completely encoded or decoded and written to memory. If the data to process is split apart in various sections of the same file, or in various files, then you can specify False in this parameter until all the source data has been read.

You can specify True for the last portion of data (which can be 0 bytes long) so that the library knows it must finish processing the source data and return the last of the processed data immediately. When specifying False, the library will expect you to call the ReadFile method again later with either a new source filename and/or source offset and/or source size.
vaBytesRead  You must provide a variable in this parameter. Right before the ReadFile method completes and returns, the library will write to the variable the amount of bytes read and processed from the source file.

Return value

Returns a byte array variant containing the processed data.

When calling the ReadFile method with the bEndOfData parameter specified as False, the returned byte array variant may not contain any data. This can happen whenever the encoder or the decoder has not received enough source data in order to output a processed block.

Associated properties

The EncodingFormat property allows you to specify which encoding format to use when encoding or decoding data.

Associated methods

ToString and FromString

Remarks

When calling the ReadFile method with the bEndOfData parameter specified as False, you cannot call any other Xceed Binary Encoding control method (of the same instance of the control) until you have completed processing a stream of data by calling the ReadFile method with the bEndOfData parameter specified as True.

Language-specific remarks

With Visual Basic, it is often necessary to convert the resulting processed data from a byte array variant to a native VB byte array before saving it or transmitting it. VB6 makes it particularly easy to do the conversion: If you have a variant named (for example) ProcessedData, you can convert it to a native VB byte array with the following code:

Visual Basic Copy Code

Dim ProcessedDataArray() As Byte
ProcessedDataArray = ProcessedData

With Microsoft Access, you can place the processed data in either a Memo field or an OLE Object field. Using an OLE Object field in a table is the easiest: You can directly assign your data to the field and conversion is automatic. To assign the processed data variant to a Memo field, use the "AppendChunk" function in Access.

Declaration (DXceedBinaryEncoding) Copy Code
HRESULT ReadFile
(
  [in] BSTR sSourceFilename,
  [in] long lSourceOffset,
  [in] long lSourceSize,
  [in] EXBFileProcessing eAction,
  [in] VARIANT_BOOL bEndOfData,
  [out] VARIANT* vaBytesRead,
  [out, retval] VARIANT* vaResult
)
Declaration (IXceedBinaryEncoding) Copy Code

HRESULT ReadFile
(
  [in] BSTR sSourceFilename,
  [in] DWORD dwSourceOffset,
  [in] DWORD dwSourceSize,
  [in] EXBFileProcessing eAction,
  [in] BOOL bEndOfData,
  [out] DWORD* pdwBytesRead,
  [size_is][out] BYTE** ppcData,
  [out, retval] DWORD* pdwDataSize
)