Hello
Need a little help, never done similar to what i'm trying to do.
So i have one file, that has one header that tells me if the bytes are in little or big endian format.
The content of the file after the file is something like this, one byte that indicates a new "section", then several bytes until the other "section". This bytes each one represent the number of the bytes that i need to read in the second section.
Sample file
and so on...Code:<Header EndianInfo> <StartSection>01 03 02 <StartSection>AA BB BB BB CC CC
So what i need to read it's AA get the decimal value, the BB BB BB and get the decimal value and CC CC and get the decimal value.
I know several ways to do this, but I don't know what's the best way to accomplish this.
For example i can do the job with this code:
VB.NET Code:
Dim BR As New IO.BinaryReader(IO.File.OpenRead(_fitActivitieFile)) BR.BaseStream.Seek(local, IO.SeekOrigin.Begin) 'Just to put in first byte that i need to read Dim currentBytes() As Byte = BR.ReadBytes(numBytes) 'Read the number of bytes that i need Debug.WriteLine(Val("&H" & BitConverter.ToString(currentBytes).Replace("-", ""))) 'BigEndian Array.Reverse(currentBytes) 'Just activate when the format it's little endian Debug.WriteLine(Val("&H" & BitConverter.ToString(currentBytes).Replace("-", ""))) 'LIttleEndian
But i don't like this version, with replaces and concatenating strings...
Can anyone show me another way to do this?
Thanks




Rate People That Helped You
Reply With Quote