473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

StreamReader vs BinaryReader

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

Nov 16 '05 #1
3 14902

"DBC User" <ks*****@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
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
Nov 16 '05 #2
Thanks but my question is "is there a reason, why Streamreader is
skipping the data?" I got it working with binarystream.

Nov 16 '05 #3
DBC User <ks*****@gmail.com> wrote:
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?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: alien | last post by:
Hi, I'm using a StreamReader (readLine()) to read text from a file, but some lines in the file I'm reading have odd characters, such as the Euro symbol, etc. I find that no matter what encoding I...
6
by: Question with BinaryReader | last post by:
I use BinaryReader to read my binary dafa files, when i call ReadBytes, why it always return more 4 bytes. The following is my code. FileStream fs = new FileStream(file, FileMode.OpenOrCreate,...
4
by: David Buchan | last post by:
Hello, I wonder if anyone could help me. I'm using vb.NET and I'd like to read a binary file, byte by byte, and then write to another file (making a duplicate, identical file). I'd then...
16
by: vvenk | last post by:
Hello: When I use either one to read a Text file, I get the same result. The length of the string that the file's content has been written into is the same. However, if the file is binary,...
1
by: Fred Nelson | last post by:
Hi: I'm writing a VB.NET web application where I would like to upload an image file from the user's computer and either insert it into a database as a BLOB or save it as a file in a directory...
8
by: Jack Russell | last post by:
I have the following code in VB.net 2003 Dim s As String Dim sr As StreamReader = New StreamReader("test.txt", New UTF7Encoding) s = sr.ReadLine Debug.Write(s) If the string read is 1+.03...
4
by: Mike R | last post by:
Hi All, I'm trying to read a file that has the following format, its a variable record file, the first byte determines how to process the rest. byte 1 = either 0,1,2,3 4 bytes = size of the...
15
by: Zytan | last post by:
I have installed the Visual C# 2005 Code Snippets, and the snippets for file handling use StreamReader and StreamWriter, instead of System.IO.File.*. VB 2005 code snippets don't use these. Why...
3
by: Tony Johansson | last post by:
Hello! I just wonder in this specific case is it any advantage to use a TextReader a reference to a StreamReader ? Try { TextReader tr = new StreamReader(locationTextBox.Text); Try {
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.