How does ResGen.exe generate resources files?

Source: Internet
Author: User
Tags net command
How does ResGen.exe generate resources files?

0 recommended

Yesterday I made a Chinese-English bilingual menu and learned it online. A convenient method is to generate a binary file-based resources from a TXT file.

The steps are as follows:

1. Edit the TXT file to be converted.

2. Run the. net command to prompt the DOS window file

3. Enter ResGen F: \ xxxx.txt F: \ xxxx. resources and press Enter.

Note that you must enter a path to generate and read the file. In addition, commands of different versions may be case-sensitive. You can run resgen.exe in the DOS window to see how to input them.

========================================================== ============================================

Appendix 1 network usage document

The resource file Generator. txt files and. the resx (XML-based resource format) file is converted to the binary format of the Common Language Runtime Library. resources file, which can be embedded into the binary executable file of the runtime or compiled into a subsidiary assembly. Resgen.exe performs the following conversions:
? Convert the. txt file to the. resources file or. resx file.
? Convert the. resources file to a text file or a. resx file.
? Convert the. resx file to a text file or. resources file.
Syntax
Resgen filename. extension [outputFilename. extension]

Parameters
Description

Filename. extension
Name of the input file to be converted. Extension must be one of the following values:
. Txt
Specifies the extension of the text file to be converted to a. resources file or. resx file. A text file can only contain string resources.
. Resx
Specify the extension of the XML-based resource file to be converted to the. resources file or. txt file.
. Resources
Specifies the extension of the resource file to be converted to a. resx or. txt file.

OutputFilename. extension
The name of the resource file to be created.
This parameter is optional when converting from A. txt or. resx file. When converting a text or. resx file to a. resources file, you can specify the. resources extension. If outputfilenameis not specified, resgen.exe adds a. resources extension to the input filename parameter and writes the file to a directory containing filename.
During conversion from the. resources file, the outputFilename parameter is mandatory. When converting the. resources file to an XML-based. resources file, specify the. resx extension. Specify the. txt extension when converting the. resources file to a text file. The. resources file should be converted to a. txt file only when the. resources file contains only string values.

Remarks
Resgen.exe encapsulates the methods implemented by the following four types to convert files:
? ResourceReader Class reads the. resources file.
? ResourceWriter Class creates the. resources file from the specified resource.
? ResXResourceReader Class reads the. resx file.
? ResXResourceWriter Class creates a. resx file from the specified resource.
Note that the. resx File Created by ResXResourceWriter cannot be directly used by the. NET application. Run Resgen.exe to convert the file to the. resources file before adding it to the application. For more information about implementing these classes in code, see their respective reference topics.
To enable Resgen.exe to analyze input data, it is critical that the. txt and. resx files follow the correct format.
A text file can only contain string resources. String resources are useful if the application being compiled must translate strings into several languages. For example, you can easily localize menu strings by using appropriate string resources. Resgen.exe reads text files containing name/value pairs. The names are strings describing resources, and the values are resource strings. Each name/value pair must be specified on each line, as shown in the following example:
Name = value
Resgen.exe checks whether duplicate resource names exist in the text file. For more information about text file formats, see Creating and Using Resources.
The. resx resource file format consists of XML items. Similar to. txt files, you can specify resources in these XML items. Compared with. txt files, the main advantage of. resx files is that they can also specify or embed objects. When viewing the. resx file, if the binary format of the embedded object (slice) is part of the resource list, you can see the binary information. Like a. txt file, you can use a text editor (such as NotePad or Microsoft Word) to open the. resx file, and write, paste, and operate its content. Note: To complete this step, you must be familiar with the XML tag and. resx file structure. For more information about the. resx file format, see Creating and Using Resources.
To create a non-String object that contains the embedded. resources file, must use the method provided by ResourceWriter Class, or use Resgen.exe to convert. resx file, or directly add the object resource to the file from the code. If Resgen.exe is used to convert the. resources file containing the object to the. txt file, all string resources will be converted correctly, but the data type of non-string objects will also be written to the file as strings. Embedded objects will be lost during the conversion process, and Resgen.exe reports errors when retrieving resources.
After the. resources file is created with Resgen.exe, use the Assembly Generation Tool (Al.exe) to embed the resource into the binary executable file of the Runtime library or compile it into a subsidiary Assembly.
Example
If no option is specified, the following command displays the command syntax and options of Resgen.exe.
Resgen
The following command reads the name/value pair in myResources.txt and writes a binary resource file named myResources. resources. Because the output file name is not explicitly specified, it receives the same name as the input file by default.
Resgen myResources.txt
The following command reads the name/value pair in myResources.txt and writes a binary resource file named yourResources. resources.
Resgen myResources.txt yourResources. resources
The following command reads the XML-based input file myResources. resx and writes a binary resource file named myResources. resources.
Resgen myResources. resx myResources. resources
The following command reads the binary resource file myResources. resources and writes an XML-based output file named myResources. resx.
Resgen myResources. resources myResources. resx
The following command reads the XML-based input file myResources. resx and writes a. txt file named myResources.txt. Note: If the. resx file contains any embedded objects, they cannot be correctly converted to. txt files.
Resgen myResources. resx myResources.txt

 

Appendix:

Http://blog.21ic.com/user1/1949/archives/2009/59680.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.