Wednesday, August 13, 2008

Retrieve Value from Resource File using C#

// Here IPOhelper is the class name under which method with following implementation is defined. and file is the file path where resource filename (without extension) is located e.g. Namespace.FileName


string resourceValue = string.Empty;
try
{

ResourceManager resourceManager = new ResourceManager(file,typeof(IOHelper).Assembly);
resourceValue = resourceManager.GetString(key);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
resourceValue = string.Empty;
}

No comments: