DKRead()

  DKRead and DKWrite

Description

DKRead() is used to read an arbitrary segment of a binary file into a buffer.

Call Signature

void DKRead ( int/string filespec, any ptr buffer, int start_byte, int num_byte )

Return Value

void

This has no return value.

Arguments

int/string filespec :

This can either be the handle returned by DBOpen(), or the name of an open file.

any ptr buffer :

An array of memory into which the data should be read. This buffer should be freed by EFree() when finished.

int start_byte :

The offset in bytes to the first byte to be read. This would be zero to read from the beginning of the file.

int num_byte :

The number of bytes to read into the buffer. The buffer must be large enough to hold this many bytes.

Remarks

DKRead() only operates on files opened in read mode with DKOpen(). It will read the requested number of bytes from the binary file, and place them in the buffer. If the buffer is not large enough to hold all the data, an error will occur. If the requested segment of the files runs past the end-of-file, the remainder will be padded out with zeros. Use DKSize() to determine the size of a file.

See also

Binary file functions

DKWrite()

DKSize()

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.