I have a binary file, I have no clue how to read this binary file using C #.
The definition of the record in the binary file described in C ++ is:
#define SIZEOF_FILE (10 * 1024) // 1234.dat file size is: 10480 + 32 bytes (32 = file header size) Typing file file record {WCHR ID [56]; WCHAR's name [56]; Int Gender; Float height; WCHH telephhen [56]; And ........} How do I read the binary file with those records in C # and edit it after I edit it?
In fact this is a struct type and StructLayout A good way to do this is to map the structure of the data in the binary file (I did not test the actual mapping, but seeing it and reading the file is about getting back to you): [Layout layout (layout kickind.Security, Charset = Charset.unicode, pack = 1)] Public structure file Reca [Marshall AS (Unequal type, Bevely, Size = 56)] Public four [] ID; [Marshall (UnmanagedType.ByValArray, SizeConst = 56)] Public four [] name; Public int gender; Public float height; // ...} class program {protected static tee redstroke & lt; t & gt; (stream stream) {byte buffer = new byte [martial size (typef (t)); stream reads (buffer, 0, Marshall Size (typef (t)); gcindal handle = gcindall.loc (buffer, gc Endless type pined); typed typed = (martial) martial.tterstroke (handle. Adrift piniyobogs (), typef (t)); Handle.Free (); Return typed straight; } Static Wide Men (String [] ARGs) (stream stream = new flamestream (@ "test.bein", flammod.open, fileexer.read)) {filerecord file record = redstroke & lieutenant; File Records & gt; (section); }}
Comments
Post a Comment