I'm looking into reading file contents. I've searched the web and started using Open, Seek & Get statements in my code. Now this does what I want it to - except it is very slow for multiple reads within each file.

So I did more research and I think it would pay if I read each file once into an array (which I will call 'buffer' from now on) and then do multiple reads within the buffer.

The only catch is that I need an alternative to 'Get' to use on the buffer. I would write the function myself but I cant get my head around how 'Get' works.


To give a real life example, say I have a file and the extract below gives me a lngGetHeader = 53691465.

    
    intFNum = FreeFile()
    Open strFileName For Binary Access Read Lock Write As intFNum
    lngReadPos = lngReadPos + 1
    Seek #intFNum, lngReadPos
    Get #intFNum, , lngGetHeader
when I try to read the same data from the buffer/array instead (extract below), I get 51?!

                
                lngReadPos = lngReadPos + 1
                lngGetHeader = avarBuffer(lngReadPos)

I know I am doing something wrong but I'm not sure what. Do I need to read multiple bytes from this position to get the long variable?