Article : Resource File Generator (Resgen.exe .Net FrameWork Tools Series)

  • Thread starter Namratha Shah \(Nasha\)
  • Start date


Namratha Shah \(Nasha\)

Hi All,

This is a resource file generation tool which converts an xml based resource formats to .net resource file i.e. (.resources) and vice-versa.

Today we will see how we will generate

==> .txt files from .resources or .resx files.

==> .resources files from text or .resx files.

==> .resx files from text or .resources files.

Let us start with converting a .txt file to resources or resx file

In order to convert from one type to another we must ensure that the data written in them is in the correct format.

Text files can only contain string resources as name=value pairs. Name here is a string that describes the resource it needs to be

unique and the value is the resource string. All these name value pairs should start from a new line.

Lets create a text file containing 10 name=value pairs;

1) Create a text file name MyText.txt.

2) Type the below name=value pairs


3) Type the following command to generate MyResources.resx from MyText.txt.

4) If you duplicated any of the entires you will get the below error message.

error: Duplicate resource key!

Else your resources will be complied successfully with the following message.

Read in 10 resources from 'MyText.txt'
Writing resource file... Done.

5) To generate .resources file from .txt file use the following command resgen MyText.txt MyResources.resources

6) To genereate .txt from .resources file or .resx file use the following commands

resgen MyResources.resx MyTextFromRes.txt
resgen MyResources.resources MyTextFromResources.txt

7) To generate .txt file from resx file or .resource file use the following commands:

resgen MyResources.resx MyTextFromRes.txt
resgen MyResources.resources MyTextFromResources.txt

There are a certain advantages or disadvantages of these format over one another :

1) Text file format name=value pair is very convient ,easy to use and create but can contain only text strings and hence you cannot embed any objects in these files.

2) Resx file format has the data in the xml format and hence you can embed objects. You will also be able to view the binary information about these objects e.g. embedding images in the resource files.


..Resources file is a binary file which is used by the assemblies
..Resx has the data in an xml format
..txt has the data in name=value format .... gr8 so many ways to represent and use your data.

To use these resource files in your assembly( as a part of your assembly) you will need to embed or link it with main assembly using assembly linker or create satellite assembly.(We will look into detail about this in tommorrow's article).

-- Please post your queries and comments for my articles in the usergroup for the benefit of all. I hope this step from my end is helpful to all of us.


Namratha (Nasha)


Jul 26, 2006
Reaction score

I'm student at Swinburne Uni, Melbourne. Write now I'm working on .resx files and related stuff and your article helps me.

Could you just let me know difference between UI-Resources and preference Data.

Thanks you in advance.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question