Hello,
I am writing an app to read in an old file structure. It C++ this is how the code looks. I am trying to rewrite it in C# and can’t find any that will do it the same way. Here is how it should work.
// This is to just explain the structure.
#define DRAWING_HEADER_FILL 888
typedef struct DrbDwgHdr {
long id;
long Vcount;
char desc[122];
char version[6];
char fill[DRAWING_HEADER_FILL];
} DRB_DWG_HDR;
typedef struct Atrb { unsigned pen:6, ltyp:4, sel:1, other:2, dsp:1, beg:1, del:1; } ATRIB;
typedef struct DRBVec {
float x_beg;
float y_beg;
float z_beg;
float x_end;
float y_end;
float z_end;
ATRIB attrib;
unsigned link;
} DRBVEC;
class CDrawingsDoc : public CDocument
{
protected: // create from serialization only
CDrawingsDoc();
DECLARE_DYNCREATE(CDrawingsDoc)
// Attributes
public:
std::vector<DRBVEC> DrawingVec;
long DrawingVecCount;
int Scale, lx_org, ly_org;
UINT m_QtyRead;
DRB_DWG_HDR DRBDwgHdr;
DRBVEC dvec;
int size;
size=sizeof(DRBVEC);
// This is the part of the Code I can’t find something compatible
// in c#
CFile f(lpszPathName, CFile::modeRead);
m_QtyRead=f.Read(&DRBDwgHdr, sizeof(DRBDwgHdr));
DrawingVec.clear();
for(long x = 0; x < DRBDwgHdr.Vcount ; x++)
{
m_QtyRead=f.Read(&dvec, size);
DrawingVec.push_back(dvec);
}
How do I read in a certain number of bytes directly into an object defined by a structure that contains floats and ints?
Thanks,
Todd