SetActiveBufferSize


The SetActiveBufferSize method sets size of active buffer. Active buffer size specifies how much file data is buffered internally.
C++

long SetActiveBufferSize(
  long Size                  // size of buffer
);
BASIC

SetActiveBufferSize(
  Size As Long               // size of buffer
) As Long

Parameters

Size
Size of active buffer.
If this parameter is 0 all data transfers are unbuffered.
If this parameter is -1 active buffer size is reset to its default value.

Return Values

If the method succeeds, the return value is 0.
If the method fails, the return value is failure code and error code is set. Call GetError to get error code.

Remarks

Active buffer size determines what part of internal data buffer is used in read and write operations; in other words it specifies how much file data is buffered internally. Developers can optimize application performance by adaptively changing active buffer size according to the size of data being accessed. This feature is especially useful if file is accessed randomly rather than sequentially - for example when reading many small blocks of data from various file positions. By default entire data buffer is used - its size is specified when Initialize method is called.

If Size is 0 data transfer is unbuffered. On read operations exact number of bytes (according to size of data) is read from file and returned to user; on write operations user data is immediately written to file. Internal data buffer always stays empty - no data is read ahead nor buffered.

Active buffer size is reset to its default value whenever new file is opened or attached to the object, so it should be changed after opening or attaching file.

See Also

GetActiveBufferSize, GetBufferSize, Initialize, Reading and Writing Data