Binary Help

Discussion in 'Programming & Scripting' started by tOxiC x, Jan 3, 2009 with 3 replies and 212 views.

  1. tOxiC x

    tOxiC x Member

    Messages:
    656
    Ratings:
    116
    I am creating something and I need it to find a string and edit the string (1-4 bytes long) a byte after. The string I want to edit it non-unicode. I have a BinaryReader sort of started, but I need help. It is slow and I need it to get faster so I was messing around and some of the code is missing now.


    Code:
            Dim search As String = "example "
    Dim br As New BinaryReader(New FileStream(fileLocation, FileMode.Open, FileAccess.Read))
    br.BaseStream.Position = &H10000
    search.???
     
  2. Michael Allison

    Michael Allison Enthusiast

    Messages:
    232
    Ratings:
    13
    If I understand correctly, why binary? Why not another encoding?

    Oh, and since Gabe says I suck at data types in general... go PM gabe_k and ask him for help, eh? :wink:
     
  3. OP
    tOxiC x

    tOxiC x Member

    Messages:
    656
    Ratings:
    116
    Binary so I can search for the string then I also have a BinaryWriter to write a new string. If gabe_k sees this, maybe he can help :wink:
     
  4. DJ Shepherd

    DJ Shepherd Banned

    Messages:
    2,325
    Ratings:
    142
    binary readers/writers dont read/write strings directly youd have to convert the string to a byte array and then make two loops, one inside the next, the first loop would read a byte and compare it to the first byte of the string

    if it does equal the byte it goes to the next loop and reads the next byte and compares it to the next letters byte, if it equals it continues until its a match to the end of the string or if not it breaks the loop and continues the previous one

    if it doesnt equal it reads the next byte and continues that search until the end of the file is reached