Short version:

I need a way to store multiple image files in one bigger file, to be used using C#, preferably easily compatible with XNA. The files will be read, written to, but also adaitional files will be added during run-time.Is there an easy way to do that?

Long version:

I'm currently working on a small student project. It's a top down RPG-strategy and we decided to make the map dynamic, meaning that portions of it will be loaded/unloaded in the background while the player character moves around.

I reckon the best way to do this is to load/generate chunks as the player comes close to them and unload them when the player goes farther. I reckon the best way to do this is to save chunk as raster graphics and then use the colour information (RGBA) to store information.

The problem is that I want certain chunks to be saved once generated so I need a way to save images, in the same way I read them, but preferably all in a single file, so as not to have the folder bloat in size with a lot of files.


1 Answer 1


You can use a container instead of a directory, storing multiple files inside it. System.IO.Packaging.ZipPackage provides one such container, starting from .NET Framework 3.0, which means you'll have to search for other implementations if you want to use such with XNA on the XBox (which only supports .NET 2.0). DotNetZip or SharpZipLib might work, but I didn't try out either yet.

The other solution would be to use an image format which supports multiple images by default, like TIFF. There is a LibTiff.Net available, which works for .NET 2.0 as well.

  • \$\begingroup\$ XNA 4.0 targets .NET 4.0 (by default the Client Profile) on Windows. So ZipPackage is available. It's just not available to XNA on Xbox/WP7. (Not to mention that older versions of XNA weren't limited to running on .NET 2.0, either). \$\endgroup\$ Aug 21, 2012 at 12:36
  • \$\begingroup\$ @AndrewRussell Since I don't know the exact target hardware the OP is asking for ... Anyway, I'll edit the answer to include the bit of information. \$\endgroup\$ Aug 21, 2012 at 12:38
  • \$\begingroup\$ I am targeting Windows, so ZipPackage seems like the way to go. \$\endgroup\$
    – Taikand
    Aug 21, 2012 at 12:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .