Re: Binary file read/write
- From: Sinna <news4sinna_NOSPAM@xxxxxxxxxx>
- Date: Wed, 09 Jul 2008 08:23:54 +0200
Dave O. wrote:
"Sinna" <news4sinna_NOSPAM@xxxxxxxxxx> wrote in message news:ehx0weM4IHA.4332@xxxxxxxxxxxxxxxxxxxxxxxYou get me correctly.Dave O. wrote:Spoilsport, you made it far too easy for him :-)Apart from a FileCopy (mentioned elsewhere), I wouldn't assume the file is 'small' enough to get it completely read in memory. When dealing with 2GB+ (and I assume quite a lot smaller too) you'll get Out of Memory errors.
I see your answer is the same as my suspicion, good to know I was correct.
At this point it might be worth pointing out to the OP that reading in (or writing out) a file byte by byte is kinda inefficient and slow, in most cases it's far better to read the whole file into a string or byte array in a single pass, then get whatever bytes are required.
Regards
Dave O.
About improving speed, when copying from a disc to another, look up the memory buffer of the disc and use that as pass-thru buffer.
Sinna
As I read it the OP was not trying to do a plain copy but was trying to understand how to read & write a file so FileCopy is not applicable.
Certainly reading a 2G file into memory in a single pass would cause problems but reading it in byte by byte would take for ever, so for huge files the best method would be to read in chucks of a few Meg at a time.
Regards
Dave O.
Copying using chuncks of a few Meg is very efficient when using chuncks <= memory buffer of the hard disc.
Sinna
.
- References:
- Binary file read/write
- From: Dan
- Re: Binary file read/write
- From: Dave O.
- Re: Binary file read/write
- From: Dan
- Re: Binary file read/write
- From: expvb
- Re: Binary file read/write
- From: Dave O.
- Re: Binary file read/write
- From: Sinna
- Re: Binary file read/write
- From: Dave O.
- Binary file read/write
- Prev by Date: Re: Use of Manifest File
- Next by Date: Re: Binary file read/write
- Previous by thread: Re: Binary file read/write
- Next by thread: Re: Binary file read/write
- Index(es):