Read value from Resource file in C#

Pass the method the name of the file you want to read from, and the key you want the value for and it returns the value

//Namespace reference
using System;
using System.Resources;

#region ReadResourceFile
/// method for reading a value from a resource file
/// (.resx file)

///file to read from ///key to get the value for /// a string value
public string ReadResourceValue(string file, string key)
//value for our return value
string resourceValue = string.Empty;
// specify your resource file name
string resourceFile = file;
// get the path of your file
string filePath = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
// create a resource manager for reading from
//the resx file
ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(resourceFile, filePath, null);
// retrieve the value of the specified key
resourceValue = resourceManager.GetString(key);
catch (Exception ex)
resourceValue = string.Empty;
return resourceValue;