Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:35:11+00:00 2026-06-16T04:35:11+00:00

I read a binary file of 900 bytes with much informations inside. Like this:

  • 0

I read a binary file of 900 bytes with much informations inside.
Like this:

     Dim myFile As String = txt_mydir.Text + "\MY_FILE.BIN"
     If IO.File.Exists(myFile) Then
        Dim fInfo As New FileInfo(myFile)
        Dim numBytes As Long = fInfo.Length
        Dim fStream As New FileStream(myFile, FileMode.Open, FileAccess.Read)
        Dim br As New BinaryReader(fStream)
        Dim data As Byte() = br.ReadBytes(CInt(numBytes))

All bytes finishes in bytearray ‘data’.

Now I have to read a numbers written with VB6 structs into that file. Structs are mine and I know what is what and where is what.
For example I need a VB.NET ‘short’ number which is at bytes 81 and 82.
Among that I have all other basic number types to get out.

How to take out desired number of bytes from ‘data’ from specific location, with exact length and get a proper number from it (short, int, double…)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:35:13+00:00Added an answer on June 16, 2026 at 4:35 am

    Use the methods of the BinaryReader to get the fields of your original struct

    Dim i As Integer = br.ReadInt32()
    Dim d As Double = br.ReadDouble()
    Dim s As String = br.ReadString()
    

    And so on. You must read the fields in exactly the same order as they were written to the file.

    Embed it into a loop like this

    While br.BaseStream.Position() <> inFile.BaseStream.Length()
        ...
    End While
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to read a binary file and use something like std::string that automatically
I'm trying to read a remote binary file (say, image) from internet like this:
I'm experiencing some problems while trying to read a binary file in C. This
I'd like to read a binary file with a few 32 bit float values
I'm trying to read a binary file 40 bytes at a time, then check
i'm trying to read a binary file (for example an executable) into a string,
I've made a code to read a binary file as follows : file=open('myfile.chn','rb') i=0
I created a read / write of bytes into a binary file using fstream
I have to read a binary file in python. This is first written by
I am trying to read a binary file and parse the bytes I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.