473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

BinaryReader C# Problem

I'm reading in a text file 602 bytes at a time, using the code below.
One of the lines has text that looks like this: "Cell#+9 and
more text here going to 602 characters for each line."

For some reason when this line is encoded the +9 is gone and
everything is moved to the left 2 bytes.

How can I get around this.

byte[] buff = new byte[602];

// Create the reader for data.
FileStream fs = new FileStream(filename, FileMode.Open,
FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
buff=r.ReadBytes(602);
line = System.Text.Encoding.ASCII.GetString(buff as
System.Byte[]);

I have also tried
System.Text.Encoding.UTF7.GetString(buff as System.Byte[]); with the
same result
Nov 20 '05 #1
2 1827
* my*********@yahoo.com (mike) scripsit:
[...]

Why do you post a C# question to /this/ group?!

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Cor
Hi Mike,

The Csharp newsgroup is two flours higher just above the Jscript newsgroup

I hope this helps

Cor
Nov 20 '05 #3

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

Similar topics

29
by: | last post by:
Hi, I am trying to optimize the reading of a huge binary file into a byte... I am doing the following.. byte ba = new byte;
2
by: Chris P. | last post by:
I have a C# application that connects to Perl application on a UNIX server. I am able to connect and communicate both directions with the server, but there are several occasions when it appears...
0
by: Denny Rue | last post by:
I’ve created VB code to download files from a web site through the use of HTTPWebRequest, HTTPWebResponse and BinaryReader. The HTTPWebRequest has a TimeOut property to limit how long it waits...
1
by: gladiator | last post by:
Hello MVPs: I am not sure when to use binaryreader in .net is best? 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...
4
by: Robert Misiak | last post by:
I've been trying out the .NET Memory Profiler (http://www.scitech.se/memprofiler/) and I found an excessive number of undisposed instances of BinaryReader after opening and then closing various...
2
by: RP2001 | last post by:
I've serialized in various variables of various types (mainly CString, int, double) into an instantiated MFC CArchive class and saved it as a binary file. I am able to open the binary file and...
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,...
1
by: Gintautas | last post by:
Hi I'm trying to make read binary file to the data array, but a problem is that the user is choosing either to read 1 byte(sbyte) or 2 bytes(Int16). So i need to make smth universal. My code:...
3
by: =?Utf-8?B?VmljdG9y?= | last post by:
Hi, Could you tell me can I keep the MemoryStream open and "close" the BinaryReader? As the MemoryStream is used for buffering the TCP data and BinaryReader is only used to read the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.