Array Capacity > 2Gb ?

  • Thread starter Thread starter Christian Reizlein
  • Start date Start date
C

Christian Reizlein

Im making a MD5 file checking program and im trying to read a file which is
larger than 2Gb. and i come across the problem that Arrays in VB.net cannot
have more than 2gb capacity, when i try to create an array of the file
length i get an overflow. is that possible? is there any workaround?

I know its going to be a lot of memory consumming to load all the file into
an array but i just dont care about that.
Any suggestions?

Thanks,
Smoke
 
Christian said:
Im making a MD5 file checking program and im trying to read a file
which is larger than 2Gb. and i come across the problem that Arrays
in VB.net cannot have more than 2gb capacity, when i try to create an
array of the file length i get an overflow. is that possible? is
there any workaround?
I know its going to be a lot of memory consumming to load all the
file into an array but i just dont care about that.
Any suggestions?

You could read the file in chunks of, say, 32KB (seeing as that's the size
of the OS's buffer AFAIK).

Andrew
 
Well, im reading it in chunks, but anyway i need a array of bytes to use as
buffer to put the read contents and that has to be the total lenght of the
file
 
I can let the md5 class to read the file directly if i just give it the
stream , but that way i cannot handle and controll the read progress of the
file and its not good, i need to read the file in chunks so i can make a
progress

if i let the md5 class read the file by itself i cannot control or know how
the read progress is beign, make sense?

sorry for my bad english...
 
I can let the md5 class to read the file directly if i just give it the
stream , but that way i cannot handle and controll the read progress of the
file and its not good, i need to read the file in chunks so i can make a
progress

if i let the md5 class read the file by itself i cannot control or know how
the read progress is beign, make sense?

sorry for my bad english...

Why don't you create a simple wrapper around the stream that reports
progress as it's read?

Basically, create a class that inherits from stream and takes the real
stream on it's constructor. You overload the methods to raise a
progress event, and then do the read off the real stream and return the
data to the md5 class.

That 1) lets you report progress and 2) makes it so you don't have to
keep the whole thing in memory.
 
Your english is fine, and probably better than mine...

You could use a marquee style progress bar. Alternatively Tom's ide makes
sense, but requires a little bit of work.
 
Yes, that sounds like the correct way to do it, but im just not sure i know
how to overload that method and raise an event (im familiar with overloads
and raise events, but not sure how to handle this one)

Do you have any reference or more help i can read to accomplish this?

Basically my question is that once i overload the read method i have no idea
how to figure out when data is beign read and lets say raise an event every
8k or so...
 
Thanks you so much for your tips, i where able to override the read method
of the filestream and raise events and control the data beign readed trough
the position property, i didnt figured that out early.

Thanks once again :)
 
Thanks you so much for your tips, i where able to override the read method
of the filestream and raise events and control the data beign readed trough
the position property, i didnt figured that out early.

Thanks once again :)

I'm glad it helped :)
 
Back
Top