473,240 Members | 1,621 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,240 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 3931
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.