StreamReader vs BinaryReader

  • Thread starter Thread starter DBC User
  • Start date Start date
D

DBC User

Hi sharpies,

Quick question. I have a file with 4 column data with line terminating
with CRLF.

name~age~data~month

Where the data is binary data. Most of the time it will be .... (binary
value of FFFFFFF). When I used the stream reader, it read all the
records correctly (used readline). But the problem is, it doesn't put
my data field with actual data, instead it put empty data. So if I have
a row

dbc~34~......~3 (Where .... binary value is FFFFFFFFF)

the program reads in dbc~34~~3.

Does anyone know why stream reader is skipping that value? I haven't
tried with binary reader yet. I will try, but just curious why
streamreader doesn't like the value.

Thanks/
DBC User
 
DBC User said:
Hi sharpies,

Quick question. I have a file with 4 column data with line terminating
with CRLF.

name~age~data~month

Where the data is binary data. Most of the time it will be .... (binary
value of FFFFFFF). When I used the stream reader, it read all the
records correctly (used readline). But the problem is, it doesn't put
my data field with actual data, instead it put empty data. So if I have
a row

dbc~34~......~3 (Where .... binary value is FFFFFFFFF)

the program reads in dbc~34~~3.

Does anyone know why stream reader is skipping that value? I haven't
tried with binary reader yet. I will try, but just curious why
streamreader doesn't like the value.


You can't have a lines terminated by CRLF and binary data. What if 0xDA
appears in the binary data?

For such a file, just open a FileStream and handle it yourself.

David
 
Thanks but my question is "is there a reason, why Streamreader is
skipping the data?" I got it working with binarystream.
 
DBC User said:
Hi sharpies,

Quick question. I have a file with 4 column data with line terminating
with CRLF.

name~age~data~month

Where the data is binary data. Most of the time it will be .... (binary
value of FFFFFFF). When I used the stream reader, it read all the
records correctly (used readline). But the problem is, it doesn't put
my data field with actual data, instead it put empty data. So if I have
a row

dbc~34~......~3 (Where .... binary value is FFFFFFFFF)

the program reads in dbc~34~~3.

Does anyone know why stream reader is skipping that value? I haven't
tried with binary reader yet. I will try, but just curious why
streamreader doesn't like the value.

StreamReaders are meant for reading text data, not binary data.
Depending on which encoding is being used, StreamReader is likely to be
reading *something*, but it may be unprintable. Which encoding are you
using?
 
Back
Top