How to create a resource file (C#, VS .NET 2003, Beginner's Level)

Posted on 2005-04-07
Last Modified: 2010-05-18
Solution must be applicable to VS .NET 2003.

How do I create a resource file for a project which is accessible by all source files in the project?
Let say I want to store 2 text strings ("red", "blue") in this resource file.
After adding these 2 strings to the resource file, how do I retrieve them in my C# code?

string myColor = GetStringResource(0)??? (I need function name  for this call.)

Question by:rj94070
    LVL 8

    Assisted Solution


    Author Comment

    No, bman9111. That's too complicated for what I want to do.
    LVL 11

    Assisted Solution

    CheckOut this article which explains how to add resources and retrive them.


    Author Comment

    That article gives me some of the info I need regarding retrieval.
    What I want to know is how to create a resource file WITHOUT having to write a program.
    How do I use a text editor to create the file? What is the format of the file, etc.?
    LVL 10

    Assisted Solution

    by:Eduard Ghergu
    There is a tool provided by Microsoft with the source code for creating the .resource files. The name is ResEditor and you'll find it after a search over the Microsoft Visual Studio.NET installation folder.
    LVL 11

    Accepted Solution

    The .NET Framework includes a sample application called ResEditor that facilitates creating and editing resource files. The ResEditor application allows you to create binary resource files (.resources) as well as XML resource files (.resX).

    Building ResEditor
    ResEditor is provided as source code with the .NET Framework SDK. Before you can use ResEditor, you must build it using the supplied batch file.

    To build the ResEditor Application

    1. Start Windows, and then click the Start button, point to All Programs, then Visual Studio .NET 2003, then Visual Studio .NET Tools, then Visual Studio .NET Command Prompt to open the Visual Studio .NET command prompt.

    2. At the command prompt, change the directory to the SDK\v1.1\Samples\Tutorials\resourcesandlocalization\reseditor folder as shown below:
    cd \Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Samples\Tutorials\resourcesandlocalization\reseditor

    3. At the command prompt, type Build, then press the ENTER key to build the application.
    ResEditor is built and the executable is placed in the \Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Samples\Tutorials\resourcesandlocalization\reseditor folder.

    The Resource File Generator ( ResGen .exe ) converts .txt files and .resx (XML-based resource format) files to common language runtime binary .resources files that can be embedded in a runtime binary executable or compiled into satellite assemblies.

    Author Comment

    Thanks, jatinderalagh. I think that reseditor is what I need. Great job.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now