views:

41

answers:

2

Currently we store report templates (word docs) as binary arrays within a dll in our C# solution.

public readonly static byte[] audit_engagement_template = new byte[] {208,207,17,224,161,177,26,225,0,0,0,0,0,0,0,0,...

Etc etc. Now this file has become HUGE and very unmanageable as Visual Studio starts using over 2.5Gb of memory whenever it is open.

We used to store this data in a database, however we need to make our database footprint as small as possible as well as reduce the bandwidth used when opening/editing these templates from the client's side. This is why we moved these files directly into the solution.

Can anyone suggest any alternatives on going about storing these files (and not allowing the clients to touch them from outside of the application)?

+4  A: 

Rather than putting them in binary arrays, try including the files as embedded resources in the DLL, then using Assembly.GetManifestResourceStream to load them. Check, but I think that may be more efficient... and it will certainly be a better separation of code and data.

Jon Skeet
Added the documents to the project's resources file. Then retrieved the byte array by simply importing the project's .Properties namespace and using Resources.xxx to retrieve the file.
Dylan
@Dylan: Hmm... I'd personally use separate files with a build action of "Embedded Resource"... but whatever works for you.
Jon Skeet
A: 

What database are you using? SQL Server will do what you want using the FILESTREAM feature. It uses the local filesystem to store the files, so they simply exist in a folder, but they are accessed via SQL. Backing up becomes much easier, and it's easy to grant read-only access.

See the MSDN article for more information.

SLC
Unfortunately that is not an option as we need to maintain backward compatibility with SQL 2000 until at least the end of this year.
Dylan