Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,051 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,698 people online right now. Registration is fast and FREE... Join Now!




BinaryReader Issues

 
Reply to this topicStart new topic

BinaryReader Issues, Reader is skipping characters

ISUMiddy
28 Feb, 2008 - 09:17 AM
Post #1

New D.I.C Head
*

Joined: 25 Jan, 2008
Posts: 5

I am using a binary reader along with the stream reader to read a data file. After I read the header lines with the stream reader I then start using the binary reader. The issue I am having is what should be the first 107 characters (different depending of the data file) that should be read is skipped, and then the binaryreader starts and runs just fine. I attached a portion of my code that starts right before I call the binary reader (br) the stream reader (sr) is reading until the end of a header that ends with the |^Data Set^| and carrage returns. so with this the binary reader does not start where the stream reader ended... rather it skippes a bunch of characters. I am attaching the datafile that I am working with.

CODE
        

       StringCheck = Convert.ToChar(sr.Read)
        While l <= 10
            StringCheck = StringCheck + Convert.ToChar(sr.Read)
            l = l + 1
        End While

        While i = 1
            StringCheck = StringCheck & Convert.ToChar(sr.Read)
            If Microsoft.VisualBasic.Right(StringCheck, 12) = "|^Data Set^|" Then
                i = 2
                StringCheck = StringCheck & Convert.ToChar(sr.Read) & Convert.ToChar(sr.Read)
            End If
        End While
        x = x & StringCheck & Chr(13) + Chr(10) & Chr(13) + Chr(10) & Chr(13) + Chr(10)
        i = 1


        Iterations = (Stepx * Stepy * NumPts) - 200

        While i < Iterations
            oneChar = (br.ReadByte())
            lastCharF1 = oneChar
            oneChar = (br.ReadByte())
            F = (oneChar And 15)
            TotalF1 = (lastCharF1) + (F * 256)

            x = x & lastCharF1 & "     ,     " & Chr(lastCharF1) & "     ,     " & F & "     ,     " & Chr(F) & "     ,     " & i & Chr(13) + Chr(10)
            i = i + 1
        End While



Attached File(s)
Attached File  test_115edited.txt ( 2.79k ) Number of downloads: 40
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:16PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month