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

  • SEARCH
  • Home
  • 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 964825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:53:37+00:00 2026-05-16T01:53:37+00:00

First I will give a little background info so this question isn’t completely without

  • 0

First I will give a little background info so this question isn’t completely without context:

I am writing a program which needs to read in binary files of which I know the format/layout. The bulk of these files contain “structs”, with the layout of each stored in the header of the file. Each struct contains fields which could be either structs or “base” types (which are not structs, and can be either value or reference types like float or String or Vector3).

I do not need to access most of the data in these files, so I would not have to define all possible structs for my current project, but there are enough that I would have to define that doing it manually would be tedious and time consuming.

My problem is that there are an extremely large number of these structs (2500+ different ones, though only the ones appearing in a file are defined in that file’s header). I would like to be able to read them in, without having to manually define each one, in a way that makes all the data available in the same way. My current thinking is that I should create a class like this:


class Struct{
  StructDefinition _def;
  List < Field > _fields;
  ...
}

In the field class I would need to be able to store both structs AND base types (or more importantly reference and value types). Is there a way to do this without turning everything into an object then casting it to the correct type when I need it? Also, is this the best way to go about reading in these files, or is there a better method?

  • 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-05-16T01:53:37+00:00Added an answer on May 16, 2026 at 1:53 am

    dynamic (.NET 4.0) can do this at runtime, but you lose compile-time type safety and IntelliSense.

    For your particular situation, I would recommend the new file mapping classes in .NET 4.0.

    If you need a pre-.NET 4.0 solution, consider looking at the file as a series of offsets instead of structures, and use a FileStream, seeking to and reading in only the information you need. This is kind of like a poor-man’s file mapping. Note that in this situation, it’s more performant if you only move forward through the file.

    Using either of these last two solutions, you don’t have to waste time and memory reading in data you won’t need anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To first give a little bit of context, my use-case is that my partner
I know one awkward solution for this taks will be : first use ct
This will be my first iOS app with any bit of complexity. I'd like
I will be writing my first daemon in php and I have a couple
I know this is wrong and gcc will give you a warning about it,
This is my first question here on stackoverflow, so I hope that I am
I've been writing a little program for fun that transfers files over TCP in
This is a multi-part question , so feel free to give input on any
First I will try to explain what I want to do. The app loads
First I will explain what I am trying to do. I am trying to

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.