Resources and Folders in VS

G

Guest

Hi,

I try to organise my Projects with folders.
For example I try to put all resource files in one folder.

When I put a resource file (.resx) in a folder I always get errors when
building.
My question is how must I refer to a resource in a folder to use it, or what
else must I do in VS for this.

Following example code shows how I 'refer' to the file F1.resx in a folder
named Resources.

class F1 : Form
{
Label pLblTest;
ResourceManager pResMan;

public F1()
{
pResMan = new ResourceManager("NamespaceName.F1",GetType().Assembly);

pLblTest = new Label();
pLblTest.Parent = this;
pLblTest.Text = pResMan.GetString("Test");
}
 
T

Tom Krueger [MSFT]

You are trying to access a reources(.rsx) file that is located in a folder
named "Resources".

To do this your code is very close. You just need to modifiy it from

pResMan = new ResourceManager("NamespaceName.F1",GetType().Assembly);

to

pResMan = new
ResourceManager("NamespaceName.Resources.F1",GetType().Assembly);

Notice I added "Resources". Also remember to change NamespaceName to the
actual default namespace that is specified for the project. You can check
this in the Project Properties.

--
Tom Krueger

My Blog - http://weblogs.asp.net/tom_krueger
Smart Client DevCenter - http://msdn.microsoft.com/smartclient/
Mobile DevCenter - http://msdn.microsoft.com/mobility

This posting is provided "as is" with no warranties and confers no rights.
 

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

Similar Threads


Top