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)

Developer technologies | VB
Developer technologies | C#
Developer technologies | 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.
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 82,856 Reputation points Volunteer Moderator
    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

  2. 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

  3. Bruce (SqlWork.com) 82,856 Reputation points Volunteer Moderator
    2023-06-13T15:39:08.2866667+00:00

    vb.net supports hex literals

    FileStream.Read(MyBytes, &H8001, 32)


  4. Viorel 126.4K 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.


Your answer

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