gladiator <gl*******@discussions.microsoft.com> wrote:
Hello MVPs:
And anyone else who care to responds, I hope.
I am not sure when to use binaryreader in .net is best?
When you're reading a *binary* file containing primitives encoded in
the way that BinaryReader understands, IME.
In fact ,I am coding a program which converts data in text files
into DB. but i have to use fixed length to read data in file(old format).
Here fixed length means the count of bytes read not the count of chars read.
because there are 2-byte chars in the data file. What about to use
binaryreader to read a text file to solve this problem.
If i use streamreader,how to accomplish it?
StreamReader sounds like the way to go. Are there line breaks between
records, by any chance? If so, just use ReadLine to read a line at a
time, and break up the string with Substring.
It's *slightly* more tricky otherwise, because you'll need to read into
a buffer of the right size repeatedly until the buffer is full, then
process that record. Far from difficult though.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too