cm007
cm007

Reputation: 1392

How to store directory structure in .NET assembly?

I wish to have a .NET assembly have a directory containing files and folders in it. The reason is that at runtime, this file/folder structure is created into a temporary directory. What is the best practice?

Should I store each file in a resource and have some sort of XML file mapping each filename to the relative directory to which it is supposed to be extracted?

Should I make a .zip file and store that .zip file in a resources? (Outside of this usage, I do not need a decompression library for my assembly, however.)

Upvotes: 0

Views: 268

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500515

EDIT: Okay, I hadn't appreciated that you needed the files as well as the directory structure.

Embedding it all within a zip file does seem to be the simplest approach, to be honest. Alternatively, you could include each file separately within the assembly and also have a structure file, for example:

<folder name="root">
  <file resource="Foo.Bar.File1" name="file.txt" />
  <folder name="child">
    <file resource="Foo.Bar.File2" name="foo.jpg" />
  </folder>
</folder>

I think that will get somewhat messy though - particularly if you have a lot of files. If it's just a few, it wouldn't be too bad...

Upvotes: 2

Related Questions