0

To read a resource for a default culture I'd do this:

object obj = GetLocalResourceObject("MyTextResourceID.Text");

But what I need is to do the same but to be able to specify a culture for the resource. So I tried this:

System.Globalization.CultureInfo cultInfo = 
    new System.Globalization.CultureInfo("en-US");

object obj = HttpContext.GetLocalResourceObject(
    "~/" + Path.GetFileName(this.Request.PhysicalPath), 
    "MyTextResourceID.Text", 
    cultInfo);

but it always returns obj as null. Any idea why?

c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • OK. My bad. I didn't have such resource in the .resx file. Easy fix :) I'll keep the code in case someone else is interested. I had a hard time finding it myself... – c00000fd May 17 '13 at 09:03
  • You can answer to your own question, add few more details and accept it. don't leave this question open if it already solved. – Damith May 17 '13 at 09:11

1 Answers1

0

OK. As suggested above, I'm answering my own question. The code above is correct and works just fine. My problem was that the resource with such ID did not exist in all .resx files.

c00000fd
  • 20,994
  • 29
  • 177
  • 400