> And in terms of speed, is StreamReader.ReadToEnd() or reading byte by
byte yourself (and handling the buffering yourself) faster?
Unless Microsoft did a really botched up job of implementing ReadToEnd I'd
say that by default the implementation of ReadToEnd will be faster than reading
byte by byte.
However, if your goal is to read the rest of the file and process it then
it depends:
with your buffering solution, would you:
- fill the buffer, process it, then throw it away or reuse it?
- fill the buffer, then keep it and allocate a new buffer for the rest?
the difference would be if you were to process a really big file, larger
than your amount of available memory. With .ReadToEnd, you might end up swapping
memory blocks to disk, which is costly. If you process the file a buffer
at a time, you might not need to as the size of the file would be irrelevant
as you only keep a buffers worth in memory anyway.
--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2