Drawbacks with reading and writing a big file to or from disk at once instead of small chunks?
Posted
by Johann Gerell
on Stack Overflow
See other posts from Stack Overflow
or by Johann Gerell
Published on 2010-04-25T20:07:31Z
Indexed on
2010/04/25
20:13 UTC
Read the original article
Hit count: 318
I work mainly on Windows and Windows CE based systems, where CreateFile
, ReadFile
and WriteFile
are the work horses, no matter if I'm in native Win32 land or in managed .Net land.
I have so far never had any obvious problem writing or reading big files in one chunk, as opposed to looping until several smaller chunks are processed. I usually delegate the IO work to a background thread that notifies me when it's done.
But looking at file IO tutorials or "textbook examples", I often find the "loop with small chunks" used without any explanation of why it's used instead of the more obvious (I dare to say!) "do it all at once".
Are there any drawbacks to the way I do that I haven't understood?
© Stack Overflow or respective owner