Special offset number in FileStream Read

Peter Volz 1,295 Reputation points
2023-06-13T15:21:23.7866667+00:00

Hello

Using FileStream.Read(MyBytes, 0, 32) I read the initial 32 bytes to read magic number.

To detect ISO CD/DVD image files, according to here, .iso file magic number is 43 44 30 30 31 but I have problem reading offset.

I don't know how to handle:

0x8001

0x8801

0x9001

Offset number is what I need to set in FileStream.Read(MyBytes, < Offset Number >, 32)

For all file types is usually 0, or 4 etc... No idea how to handle HEX number here? (main code in VB)

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,114 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,755 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Viorel 118.5K Reputation points
    2023-06-13T15:34:18.9966667+00:00

    Try this:

    fileStream.Position = 0x8001;
    fileStream.Read(MyBytes, 0, 5);
    

    Repeat it for 0x8801 and 0x9001.


  2. Bruce (SqlWork.com) 68,236 Reputation points
    2023-06-13T15:39:08.2866667+00:00

    vb.net supports hex literals

    FileStream.Read(MyBytes, &H8001, 32)


  3. Peter Volz 1,295 Reputation points
    2023-06-13T15:55:45.11+00:00

    oh, if I'm not wrong, 0x8001 equals 32769, does it mean:

    FileStream.Read(MyBytes, 32769, 32)

    ?

    0 comments No comments

  4. Bruce (SqlWork.com) 68,236 Reputation points
    2023-06-13T19:51:56.1+00:00

    yes, you can convert the hex value to decimal rather than letting the compiler do it. in both cases the compiler converts to binary.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.