How to Create a Resource File From a Text File - VB.NET


  • I am using Visual Studio 2008 and programming in VB. I have a question about how to create and use resources files.

    I am trying to create a resources file from a text file (e.g. from myRes.txt to myRes.resx) using RESGEN.EXE. After creating myRes.resx, I want to then add it to my application so that I can access strings in it by using the My.Resources object. In this way, it would operate in the same way as a resources file created by going into Project>Add New Item...> Resources File. I used the following command to create the myRes.resx file:

    resgen myRes.txt myRes.resx

    I then included myRes.resx in my project, but after do this I was not able to access

    it with intellisense. Am I missing a step? The current property values for

    myRes.resx are as follows:

    Build Action = Embedded Resource

    Copy to Output Directory = Do not copy

    Custom Tool = Nothing

    Custom Tool Namespace = Nothing

    File Name = myNewTest.resx

    Any suggestions?

    Sunday, October 28, 2012 4:26 PM


All replies

  • I believe that command line produces a binary .resource file despite the name that you assign it.  You may need to call resgen twice to produce an XML-based output .resx file.  Please review the documentation here.

    Rudy   =8^D

    Mark the best replies as answers. "Fooling computers since 1971."

    Sunday, October 28, 2012 5:50 PM
  • The resources are in .Net Visual Studio a part which can be embedded into the assembly by doing 

    Project -> Project Properties -> Resources.

    You can than add strings, images, sound (wav) and objects. That becomes serialized in the assembly.

    For windows forms there is an RESX which can be used with more natural languages. All those who I know who tried it were stopping after a month and created something themselves (XLM or likewise).

    Be aware that you also can use the Settings to put data in the config.sys, which is also an XML file.

    To make it more clear what I wrote above. Did you ever buy a Microsoft product which had for languages an RESX file?.


    Sunday, October 28, 2012 8:36 PM
  • Cor, here is a neat web page gizmo.

    Microsoft Translator Widget.

    No more writing .resx files to translate your web pages into other languages. 

    MSDN Documentation for Microsoft Translator.

    Rudy  [insert your big smiling, winking, yellow, smiley face]

    Mark the best replies as answers. "Fooling computers since 1971."

    Sunday, October 28, 2012 10:37 PM
  • Thanks for the suggestion Rudy,

    I actually started with the documentation that you posted in your response; it wasn't very clear though. I've still not been able to go from text file to .resx file. 

    I am aware that I can add resources by using Project -> Project Properties -> Resources. This is not the approach I want to use. I have a few hundred strings representing prompts, labels, captions that have been translated to another language. I don't want to enter them individually since this would take a fair bit of time.
    Tuesday, October 30, 2012 4:04 PM
  • Look at the documentation.  Your posted command line creates a binary .resource file, according to the posted command line examples. 

    resgen myResources.restext yourResources.resources

    Another example shows how to create XML from a .resource file. 

    resgen myResources.resources myResources.resx

    Run the command twice.

    Rudy   =8^D

    Mark the best replies as answers. "Fooling computers since 1971."

    Friday, November 02, 2012 1:50 PM