Reputation: 1053
I have a open source project I downloaded to help me through a byte array. I need to convert
int x = fgetc(inpFile);
x |= fgetc(inputfile) <<8;
x |= fgetc(inputfile) <<16;
x |= fgetc(inputfile) <<24;
to vb.net. The fgetc and inpFile I understand. Unfortunately I don't know C++ and I am thin on bitwise operations.
The file format I am trying to interpret (I'm working on an embroidery format reader) is poorly documented, and instructs me that "Address HEX 0008 to 0010 = 3 Bytes pointing to beginning of .... next block of byte array ... "
I'm simply trying to calculate the same value from these three bytes that the example code above does.
Hope this makes sense
Upvotes: 2
Views: 146
Reputation: 140230
You could go with BinaryReader
, that automatically reads in Little Endian.
Dim reader As BinaryReader
Dim x As Integer
reader = New BinaryReader(File.Open(fileName, FileMode.Open))
x = reader.ReadInt32()
Upvotes: 1
Reputation: 20120
i will go with this
dim x as integer = fgetc(inpFile) or
fgetc(inpFile) << 8 or
fgetc(inpFile) << 16 or
fgetc(inpFile) <<24
Upvotes: 3