Efficiently reading bytes from a FileStream

J

James Dean

I create a new filestream and then i move i use the readbyte function
and the position function when required. These seem to be cripplingly
slow for some reason. This readbyte maybe is the problem. Do i need to
use a binaryReader with this in order for it to be faster?. I am
manipulating a compressed image file. Because i am reading in so many
bytes it makes it inefficient. Could somebody have a suggestion as how
to remedy this problem.



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
N

Niki Estner

You should use the Stream.Read function, reading blocks of at least a few
thousand bytes at a time. System calls take time. Using one per byte *is*
cripplingly slow. If you really want to use the "readbyte" function, use a
System.IO.BufferedStream. This will at least buffer the system calls - but
you would still have one method call per byte.

Niki
 
J

James Dean

Hey i used the function that he recommended in that page you gave me. I
just want to say thanks alot it has really helped enormously......

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top