Results 1 to 2 of 2

Thread: Byte write order

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2015
    Posts
    46

    Byte write order

    Code:
                Using fs As New FileStream(OFD.FileName, FileMode.Open, FileAccess.Write, FileShare.None)
                    Using writer As New BinaryWriter(fs)
                        writer.Seek(&H20, SeekOrigin.Begin)
                        writer.Write(CUShort(&H2903))
    The problem is: It should write 29 03 to file, but it wrote 03 29 alwyas
    Just need to flip this values.

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,117

    Re: Byte write order

    If you're going to write a literal value, you can just swap the bytes yourself.
    writer.Write(CUShort(&H329))
    If you have a variable that you want to write at that address, then you could use the code dday9 gave you earlier to swap the two bytes (probably into another variable so you don't change your source) and write that.
    Or, you could use the BitConverter.GetBytes to get the value into an array of bytes then write each byte out in the order you want.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width