views:

26

answers:

1

I have a large raw data file (up to 1GB) which contains raw samples from a USB data logger.

I need to store extra information relating to the file (sample rate, description, trigger point, last seek position etc) and was looking into adding this as a some sort of header.

The header file should ideally be human readable and flexible so I've so far ruled out some sort of binary serialization into a header.

I also want to avoid two separate files as they could end up separated when copied or backed up. I remembered somebody telling me that newer *.*x Microsoft Office documents are actually a number of files in a zip. Is there a simple way to achieve this? Could I still keep the quick seek times to the raw file?

Update

I started using the binary serializer and found it to be a pain. I ended up using the xml serializer as I'm more comfortable using it. I reserve some space at the start of the files for the xml. Simple

+1  A: 

When you say you want to make the header human readable, this suggests opening the file in a text editor. Do you really want to do this considering the file size and (I'm assuming), the remainder of the file being non-human readable binary data? If it is, just write the text header data to the start of the binary file - it will be visible when the file is opened but, of course, the remainder of the file will look like garbage.

You could create an uncompressed ZIP archive, which may allow you to seek directly to the binary data. See this for information on creating a ZIP archive: http://weblogs.asp.net/jgalloway/archive/2007/10/25/creating-zip-archives-in-net-without-an-external-library-like-sharpziplib.aspx

Daniel Renshaw
I might just scrap the human readable idea. My add can read the header anyway...
Tim