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

Discussion in 'ASP .Net' started by Namratha Shah \(Nasha\), Nov 2, 2004.

  1. 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)
     
    Namratha Shah \(Nasha\), Nov 2, 2004
    #1
    1. Advertising

  2. Namratha Shah \(Nasha\)

    Rony.Swinburne

    Joined:
    Jul 26, 2006
    Messages:
    1
    Hi,

    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.

    Cheers,
    Rony
     
    Rony.Swinburne, Jul 26, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Namratha Shah \(Nasha\)
    Replies:
    0
    Views:
    4,713
    Namratha Shah \(Nasha\)
    Nov 5, 2004
  2. Namratha Shah \(Nasha\)
    Replies:
    0
    Views:
    613
    Namratha Shah \(Nasha\)
    Nov 23, 2004
  3. Namratha Shah \(Nasha\)

    Article : Security Tools Part -- 2 (.Net FrameWork Tools Series)

    Namratha Shah \(Nasha\), Nov 23, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    207
    Namratha Shah \(Nasha\)
    Nov 23, 2004
  4. Namratha Shah \(Nasha\)

    Article : Security Tools Part -- 2 (.Net FrameWork Tools Series)

    Namratha Shah \(Nasha\), Nov 23, 2004, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    200
    Namratha Shah \(Nasha\)
    Nov 23, 2004
  5. Namratha Shah \(Nasha\)

    Article : Security Tools Part -- 2 (.Net FrameWork Tools Series)

    Namratha Shah \(Nasha\), Nov 23, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    219
    Namratha Shah \(Nasha\)
    Nov 23, 2004
Loading...

Share This Page