CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006
    Posts
    357

    [RESOLVED] reading and writing structs with streams?

    Hey,

    In C++ its easy enough to just read bytes from a file into a struct, does C# offer anything similar?

    Im doing alot of work at the moment with older files that all have headers then pre-defined blocks, and have got by so far with just using a binary reader and manually populating the structures, but im getting to a point now where it is getting quite time consuming to do this for each file type as some structures are huge, especially given that they all need tests written for them too.

    I was ideally hoping for some sort of code along the lines of:

    Code:
    MyStructType myStruct = myStream.ReadStruct<MyStructType>();
    My structs are all using sequential layout, i havent bothered changing the pack size yet.

  2. #2
    Join Date
    Nov 2006
    Posts
    357

    Re: reading and writing structs with streams?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured