resx Files

When you add a resx file to your project it is an xml file that
can contain resources. Under the file’s properties you have
‘Build Action’. You can’t set it to ‘Compile’ because it isn’t
C# or VB.NET code. Setting it to ‘Embedded Resource’ includes
the resources in the project’s assembly. You don’t have to do
anything further. Just add whatever you want to the resx file.
The disadvantage is that you can’t change the content
dynamically once the program is compiled. The resources are
now in the assembly and not (directly) available (there ARE tools
to get to them). Setting the property to ‘Content’ doesn’t
include the resources in the assembly. They remain a
separate file having the advantage that you can change them
dynamically once your program is compiled.
The disadvantage is that your program can’t read the resources
straight away. You have to convert the .resx file to a .resource
file using the resgen.exe tool.

Here is how to access a resource text in code by it’s name:

 this .label.Text = ResxFileName.Name;


this.label.Text = ResxFileName.ResourceManager.GetString(“Name”);


%d bloggers like this: