How to access a resource file that's not in the root of the Resources folder? (Sharepoint 2010)

2.7k views Asked by At

I followed this tutorial to create a resource file named GlobalResources.resx under Resources.

Resources file in root

I am able to access the content of the resource file using:

string resourceVal = SPUtility.GetLocalizedString("$Resources:GlobalResources, ResourceKey", "GlobalResources", language);


However, to follow company coding standards, I am required to move the resources file into a folder named <client>.<department>.<project>.<farm|sandbox>.
So I did this:

Resource file in sub-folder

But now I'm not able access the resource values!

I tried the following...

(a)

SPUtility.GetLocalizedString("$Resources:Comp.Dept.Proj.Farm/GlobalResources, ResourceKey", "Comp.Dept.Proj.Farm/GlobalResources", language);

(b)

SPUtility.GetLocalizedString("$Resources:Comp.Dept.Proj.Farm\\GlobalResources, ResourceKey", "Comp.Dept.Proj.Farm\\GlobalResources", language);

(c)

SPUtility.GetLocalizedString("$Resources:Comp.Dept.Proj.Farm.GlobalResources, ResourceKey", "Comp.Dept.Proj.Farm.GlobalResources", language);

...but none of them worked.

How do I access the resource file that's not in the root of the Resources folder?

1

There are 1 answers

0
SNag On BEST ANSWER

I received an answer to this question here.

This worked:

string resourceVal = SPUtility.GetLocalizedString("$Resources:ResourceKey",
"Comp.Dept.Proj.Farm\\GlobalResources", language);