Groups | Blog | Home
all groups > vb.net upgrade > november 2004 >

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


Namratha Shah \(Nasha\)
11/3/2004 12:26:01 AM
This is a multi-part message in MIME format.

------=_NextPart_000_0039_01C4C13B.B2BAE300
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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

=3D=3D> .txt files from .resources or .resx files.=20

=3D=3D> .resources files from text or .resx files.=20

=3D=3D> .resx files from text or .resources files.=20

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

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

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

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

Lets create a text file containing 10 name=3Dvalue pairs;=20

1) Create a text file name MyText.txt.


2) Type the below name=3Dvalue pairs=20

name1=3Dvalue
name2=3Dvalue
name3=3Dvalue
name4=3Dvalue
name5=3Dvalue
name6=3Dvalue
name7=3Dvalue
name8=3Dvalue
name9=3Dvalue
name10=3Dvalue=20

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

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

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

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

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

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



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

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

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

1) Text file format name=3Dvalue 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.=20

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=3Dvalue format .... gr8 so many ways to =
represent and use your data.=20

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

Regards,

Namratha (Nasha)


------=_NextPart_000_0039_01C4C13B.B2BAE300
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD><FONT face=3DArial><FONT size=3D2>
<BODY>
<DIV>
<DIV>
<P><FONT face=3DArial size=3D2>Hi All,</FONT></P>
<P><FONT face=3DArial size=3D2>This is a resource file generation tool =
which=20
converts an xml based resource formats to .net resource file i.e. =
(.resources)=20
and vice-versa. </FONT></P>
<P><FONT face=3DArial size=3D2>Today we will see how we will =
generate</FONT></P>
<P><FONT face=3DArial size=3D2>=3D=3D&gt; .txt files from .resources or =
..resx files.=20
</FONT></P>
<P><FONT face=3DArial size=3D2>=3D=3D&gt; .resources files from text or =
..resx files.=20
</FONT></P>
<P><FONT face=3DArial size=3D2>=3D=3D&gt; .resx files from text or =
..resources files.=20
</FONT></P>
<P><FONT face=3DArial size=3D2>Let us start with converting a .txt file =
to resources=20
or resx file </FONT></P>
<P><FONT face=3DArial size=3D2>In order to convert from one type to =
another we must=20
ensure that the data written in them is in the correct format. =
</FONT></P>
<P><FONT face=3DArial size=3D2>Text files can only contain string =
resources as=20
name=3Dvalue pairs. Name here is a string that describes the resource it =
needs to=20
be </FONT></P>
<P><FONT face=3DArial size=3D2>unique and the value is the resource =
string. All=20
these name value pairs should start from a new line. </FONT></P>
<P><FONT face=3DArial size=3D2>Lets create a text file containing 10 =
name=3Dvalue=20
pairs; </FONT></P>
<P><FONT face=3DArial size=3D2>1) Create a text file name =
MyText.txt.</FONT></P>
<P><BR><FONT face=3DArial size=3D2>2) Type the below name=3Dvalue pairs =
</FONT></P>
<P><FONT face=3DArial color=3D#0000ff=20
size=3D2>name1=3Dvalue<BR>name2=3Dvalue<BR>name3=3Dvalue<BR>name4=3Dvalue=
<BR>name5=3Dvalue<BR>name6=3Dvalue<BR>name7=3Dvalue<BR>name8=3Dvalue<BR>n=
ame9=3Dvalue<BR>name10=3Dvalue=20
</FONT></P>
<P><FONT face=3DArial size=3D2>3) Type the following command to generate =

MyResources.resx from MyText.txt. </FONT></P>
<P><FONT face=3DArial size=3D2>4) If you duplicated any of the entires =
you will get=20
the below error message. </FONT></P>
<P><FONT face=3DArial color=3D#ff0000 size=3D2>error: Duplicate resource =

key!</FONT></P>
<P><FONT face=3DArial size=3D2></FONT><BR><FONT face=3DArial =
size=3D2>Else your=20
resources will be complied successfully with the following =
message.</FONT></P>
<P><BR><FONT face=3DArial size=3D2><FONT color=3D#800000>Read in 10 =
resources from=20
'MyText.txt'<BR>Writing resource file... Done.</FONT> </FONT></P>
<P><FONT face=3DArial size=3D2>5) To generate .resources file from .txt =
file use the=20
following command resgen MyText.txt MyResources.resources </FONT></P>
<P><FONT face=3DArial size=3D2>6) To genereate .txt from .resources file =
or .resx=20
file use the following commands</FONT></P>
<P><FONT face=3DArial color=3D#0000ff size=3D2>resgen MyResources.resx=20
MyTextFromRes.txt<BR>resgen MyResources.resources =
MyTextFromResources.txt=20
</FONT></P>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<P><FONT face=3DArial size=3D2>7) To generate .txt file from resx file =
or .resource=20
file use the following commands: </FONT></P>
<P><FONT face=3DArial size=3D2><FONT color=3D#0000ff>resgen =
cms123
12/2/2004 6:35:01 AM
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

[quoted text, click to view]
AddThis Social Bookmark Button