VB6 - Huge (>2GB) Text and Binary File I/O Classes
I swear I did a search or two first but I hadn't seen this here.
HugeBinaryFile.cls is a VB6 Class that is based on an old MS KB article for VB4.
It works a bit like using Get#/Put# with Byte arrays, and supports absolute seeks to a byte position using a Currency value from 0 to far beyond the usual 2GB limit. It can also do seeks relative to the current file position accepting a signed Long value, and seek to EOF for appending. Its FileLen property returns the open file's length in bytes as a Currency value.
Currency was used for convenience since huge files need a 64-bit position value. Since Currency values have an implied decimal point the class does scaling so that you can use 1 to mean 1 (1.0000) instead of using 0.0001 to mean byte 1.
If you find this imperfect you can always modify the Class to accept and return a pair of unsigned Long values instead. In the end these can get pretty clumsy to work with though.
I did a certain amount of testing, but I won't claim this code is bug-free.
The Class is provided here bundled in a small demo project. To add it to your own projects simply copy the .cls file into your project folder and Add|File... to make it part of your project.
It would be fairly easy to create another Class that wraps this one for doing text I/O.
Look at the posts below for my HugeTextFile class.
Last edited by dilettante; Jun 27th, 2011 at 05:37 PM.
Reason: Added HugeTextFile Class