How to use data of a ".resx" file integrated in a ".exe" with VS ?

A

AndreB

Hi,

I've noticed that values added to a ".resx" file that is integrated in a VS
project are included in the final ".exe" (as lines of a ".rc" where included
in a ".exe" with C++).
How can I read the "value", "comment" and "mimetype" associated with a
"name"
without readin the original ".resx" of the project because I will not ship
it
to the user (as data are the the ".exe" application".

I've tried ResxResourceReader bat I can't construct its object without
specifying
the ".resx" file name.

I want to read data included in app.exe like "LoadString()" in C++.

Any help, TIA, AndreB.
 
A

AndreB

I found the solution...

a) Within the XML ".resx" file of my solution, I add at the end:
<data name="1">
<value>Titi</value>
</data>
<data name="2">
<value>Toto</value>
</data>
<data name="999">
<value>Tata</value>
</data>

b) In my code, I add:
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(MyApp));
string varString = ((System.String)(resources.GetObject("1")));
varString = ((System.String)(resources.GetObject("2")));
varString = ((System.String)(resources.GetObject("999")));

c) And I get first: "Titi", "Toto" and "Tata".

So, I can read my resources lines at Runtime in the same way I was able to
read StringTable in C++.

AndreB.
********************
 
A

AndreB

In addition:

a) Create your "MyFile.resx" and add line {"name1","Value1"} and
{"name2","Value2"}
b) Code those lines to read values:
string varString;
System.Resources.ResourceManager rm = new
System.Resources.ResourceManager("MyNamespace.MyFile",
this.GetType().Assembly);
varString = rm.GetString("name1");
varString = rm.GetString("name2");

AndreB.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top