Reading a file

Rothchild

New member
Joined
Mar 12, 2012
Messages
3
Programming Experience
Beginner
I want to read some information from a .Sims3Pack file. Here's a link to the file format information. I only want to read the XML section. What is the easiest way to do this? Any assistance would be greatly appreciated. Thank you for your time.
 
DWORD means UInteger/UInt32 data type (4 bytes) and WORD means UShort/UInt16 data type (2 bytes).
You can for example use a BinaryReader or a FileStream to extract content.
The byte content of the xml can be transferred to a temporary file or a MemoryStream and read from there using regular xml tools.
 
Thank you, BinaryReader seems to be what I'm looking for.
I was able to use BinaryReader.ReadUInt32() to read DWORD StrLength on all the files, which is always 7.
I set BinaryReader.BaseStream.Position=13 and used BinaryReader.ReadInt32() to read
DWORD XMLLength which gave me 8640.
I then tried BinaryReader.
ReadChars(8640) and it starts at the correct position but gives me too much data. Looking at the file with a hex editor shows shows DWORD XMLLength is "C0 21 00 00" and the XML data ends at offset 21C0. What am I doing wrong?
 
I would use ReadUInt32/ReadUInt16/ReadBytes methods only, and not meddle with basestream position.
You will find byte count, which can be difficult to translate to ReadChars that read chars taking from 1 to 4 bytes in utf8 encoding. Just grab the byte content and put that in a MemoryStream.
 
Back
Top