Resource File Creator

 

This is the first product of my Resource File research project I have been working on in my spare time.  I have at least one more tool that I will be releasing the code to like this one, before I actually put the complete article (or whatever you want to call it) up on the site.  This download includes the ResourceFileCreateor solution.  It is written in C# in VS.net 2003.  There are 3 projects in the solution: ResourceFileCreator (dll), RFC (exe), and WinResourceFileCreator (exe).

 

Before learning how to use resources in our code, we need to have a resource file… that is where either the GUI projectWinResourceFileCreator or the console project – RFC come in.

 

WinResourceFileCreator

This utility (shown below) is a simple Windows Forms application that will create a resource file (either resx or resources) with the files that you choose.  Currently it only creates resource files, it will not load them and let you edit the contents.  If you want to do that I recommend getting Lutz Roeder’s Resource (see resources section at end of this page).  The only file types that are currently supported are bmp, jpg, gif, ico and txt.  Any file added with the txt extension is going to be parsed for name=value type resources.  What this gives you is the ability to put all of your strings into one text file and then add them all to the resource file in one click (this is like the Resgen.exe that comes with the .Net SDK).  In fact the resgen.exe does more than either of my samples here – so you should check it out. 

 

The advantages of the WinResourceFileCreator are:

  1. You have the code to see how it works
  2. It has a GUI

 

 

RFC

This utility has similar functionality as the WinResourceFileCreator except that it can do one more thing – add all files in a given directory to a resource file.  This gives you the convenience of putting all of your images and text files (with all of your strings to be used) in one directory, point the RFC utility at it and create the resources file in one call.  There are currently only 3 switches:

 

 

A full example that would take all the files under the images directory would be:

RFC –d:c:\images –o:c:\images\appResources.resources

 

 

The advantages of RFC are:

  1. You have the code to see how it works
  2. You can add all files in one directory very easily

 

Personally I think the most useful feature out of either of these sample applications is the ability to add all files in a given directory.  If you are interested in how to create resource files in .Net, download the code and see what it looks like.

 

The next utility will be an application that takes a resources file and generates a strongly typed class wrapper around the resources for either C# or VB.

 

Resources

Source Code for this sample

Resource File Generator (Resgen.exe) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfresourcefilegeneratorutilityresgenexe.asp

 

Lutz Roeder’s Resourcer can be found at: http://www.aisto.com/roeder/DotNet/