shapper said:
But if the xml file is being continued updated and files continued
added will not be to heavy on the application to continuously zip it?
If the XML file is being continually updated and files continued to be
added, won't that be "too heavy" on the application to continuously have
to rewrite the XML and associated binary files?
The fact is, there is overhead in maintaining data. A composite file,
such as a .zip or even an uncompressed format like .tar, will involve
overhead in rewriting the file when changes are made. The best way to
avoid that is to avoid making changes. In any case, if you do have
compression involved, that won't be the main cost. The main cost will
be the i/o for the file.
Of course, if the binary files are themselves not changing, then you can
perhaps gain some efficiency by leaving them separate and only rewriting
the XML. But a) it's not clear from your question that's in fact the
case, and b) there is still value in not spreading your data all around,
even if it is the case.
In this case I don't have the need to share with others ...
Any activity that involves moving or copying this data is relevant,
whether you are the only person involved or not.
When you say create my own wrapper file what do you mean?
My suggestion that you _can_ create your own container file format is
simply that: come up with your own binary format for the file, and
implement that. There's nothing magic about any of the other file
formats; they are simply a stream of bytes arranged in a particular way.
So, decide what arrangement of your bytes is most useful and simplest to
implement for you, and arrange the bytes that way.
One argument in favor of some of the more standard formats is that there
may already be libraries that exist for handling those formats. If so,
you may find it better to use them than to create your own, just because
there's less work involved.
How can this be done in C#?
The same as for any file format. Write the bytes to the file in the
right order.
And again should it be done when the files are continued changed?
It just depends. But generally, I'd say the answer is "yes". If the
data need to be kept together, the simplest way to enforce that is to
make sure they are all in the same file in the first place. Simplicity,
maintainability, and ease-of-use trump other considerations most of the
time.
As the overhead of maintaining a combined file format becomes too costly
for your application, then of course you may find that answer
insufficient. It depends a lot on the size of the files involved, how
often the binary data itself changes, etc.
Note that as a compromise approach, you may find it beneficial to use a
subdirectory in the file system itself as your "folder". This is harder
to enforce, but it's much simpler to implement, and would be more
efficient if you are able to avoid rewriting the binary file parts of
your data when changes not involving them are made.
Pete