The exact structure of the structure is not important.
From what I am compiling, the following c-code reads a “piece” of binary data (equal to the size of the structure) and writes it directly to the structure (that is, first 32 bytes to name, the next 2 bytes for the attribute, etc. ) Are there any equivalents in C # managed code?
Please provide a sniper code showing a similar result. To save time, you can simplify only a few elements and assume that the corresponding filter type object is already initialized.
Note. I will use the existing old data file, so formatting / packing an existing data file is important. For example, I cannot simply use .net serialization / deserialization because I will process obsolete existing files (format change is not possible).
typedef struct _PDB
{
char name[32];
unsigned short attrib;
unsigned short version;
unsigned int created;
unsigned int modified;
unsigned int backup;
unsigned int modNum;
unsigned int nextRecordListID;
unsigned short numRecs;
} PDB;
void getFileType(FILE *in)
{
PDB p;
fseek(in, 0, SEEK_SET);
fread(&p, sizeof(p), 1, in);
. . .
}
source
share