473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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

name1=value
name2=value
name3=value
name4=value
name5=value
name6=value
name7=value
name8=value
name9=value
name10=value

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.

Thus

..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.

Regards,

Namratha (Nasha)
Nov 17 '05 #1
1 3967
I see resx file is generated automaticely for .aspx file. do you know how to
generate a resx file for a project automaticely? and how to modify a resource
fileafter it is generate? it seams crash easily. Thanks for help.

cms123

"Namratha Shah (Nasha)" wrote:
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

name1=value
name2=value
name3=value
name4=value
name5=value
name6=value
name7=value
name8=value
name9=value
name10=value

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.

Thus

..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.

Regards,

Namratha (Nasha)

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dan H. | last post by:
Hello, What is the equivalent "string resource file" in c#? And, is there a way to create a beep in C#? Thanks, Dan
5
by: Code Guy | last post by:
Hello, I am trying to execute the following code: private void button1_Click(object sender, System.EventArgs e) { PictureBox c = new PictureBox(); c.BorderStyle = BorderStyle.FixedSingle;...
0
by: Namratha Shah \(Nasha\) | last post by:
Hi All, Assembly linker is a tool which is used to create an assembly by combining one or more .netmodules and resource files. In simple words an .netmodule is an IL file that does not have ...
2
by: Dave L | last post by:
I have a Managed C++ DLL used by a C# application. I'm building with VS .NET 2002. I have a resx file loaded with string data. The C# application can access the string data fine, like so: ...
1
by: sam | last post by:
Hi, I am using resources files in my aspnet app. I have a .txt file with key value pairs which gets compiled into a .resource file using resgen.exe. I access the .resource file using:...
1
by: Jon | last post by:
One of the quickstarts for localization has an example of how to make a DLL out of a resrouce file. In the example, they do the following: resgen string.txt string.resources al /embed...yada...
1
by: urban.john | last post by:
Here are my steps: create resource files from resx files: <echo message="CREATING RESOURCE FILES FROM RESGEN EN" /> <resgen todir="product\resources_en" verbose="true"> <resources> <include...
0
by: GT | last post by:
This question has been posted before, but without any response so therefore I'm trying once more. I'm trying to embed .resource files into a Windows application in VS2005, and then compile and...
8
by: CodeLeon | last post by:
Hi, All. I am creating a setup program. The way it works is that the user creates their setup info, my program generates the C# code for a setup executable, embeds the xml file containing the info...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.