Re: read file > 2 GB

Tech-Archive recommends: Fix windows errors by optimizing your registry



2^31 is actually 2147483648, i.e. you were right before.

However, the maximum signed value you can store in <n> bits is 2^n-1, and
2^31-1 is 2147483647, which is basically what Bob said :-)

Tony Proctor

"kpg" <no@xxxxxxxx> wrote in message
news:Xns98BC9EA077A64ipostthereforeiam@xxxxxxxxxxxxxxxx
Bob O`Bob <filterbob@xxxxxxxxxxxxxxx> wrote in
news:upMnK4zOHHA.4992@xxxxxxxxxxxxxxxxxxxx:

kpg wrote:
hi all,

I need to read a binary file > 2GB. (17GB in this case)

So I'm trying to use the setfilepointer API, which
accepts 64 bit integers.

I could write a function to take my large offset and split it into
high/low 32 bit numbers, but for a quick test I thought I would just
loop (offset/max_long) number of times, moving the file pointer from
the current location each time. (max_long = 2^31) than finally moving
the reaminder. This way I'm staying with 32 bit numbers, and just
pass a null as the high order long (per the documentation).

Well when I pass max_long to the SetFilePointer routine it complains
about overflow, so I'm sure I'm messing up on some of the finer
points of api usage.

Anyone got any large file vb6 api (or non-api) references?

thanks

kpg

the number you're calling "max_long" is off by 1.

the actual upper limit is /well-specified in the help files as/
"2,147,483,647" which, you will note, is NOT AN EVEN NUMBER.


Bob

OK, 2^31 on my calculator is 2147483647 (oddly enough, um, pun intended)

...but you are quite right, it should be even!

Well, as it turns out to ensure accuracy I did not type in the number, I
just did a ? 2^31 in the immediate window and I got 2147483648, which I
dutyfully pasted without any further thought.

Good call, Bob,

Course, what I was really fishing for was an API example if someone had
one handy - but I expect I'm on my way now.

It's been that kind of a day. Now I have to live with the fact that my
calculator can't do math any better than I can.

kpg



.



Relevant Pages

  • Re: read file > 2 GB
    ... kpg wrote: ... So I'm trying to use the setfilepointer API, ... moving the file pointer from ... of api usage. ...
    (microsoft.public.vb.general.discussion)
  • Re: read file > 2 GB
    ... So I'm trying to use the setfilepointer API, ... points of api usage. ... Good call, Bob, ... calculator can't do math any better than I can. ...
    (microsoft.public.vb.general.discussion)
  • read file > 2 GB
    ... I need to read a binary file> 2GB. ... So I'm trying to use the setfilepointer API, ... moving the file pointer from ... of api usage. ...
    (microsoft.public.vb.general.discussion)
  • Re: Why no serious MS Application in .NET yet ??
    ... Anf that is why there is not a wrapper API for DDE. ... supporting existing APIs and moving forward? ... "CMM" wrote: ...
    (microsoft.public.dotnet.framework)
  • Re: Why no serious MS Application in .NET yet ??
    ... Anf that is why there is not a wrapper API for DDE. ... supporting existing APIs and moving forward? ... "CMM" wrote: ...
    (microsoft.public.dotnet.framework.performance)