I have an enum with some data on it, also I have a resource file with the same data of the enum but using different translation
Ex.
enum test
{
Sun =1,
Mon = 2
}
The resource file : Text.resx
Sun --> Sunday
Mon --> Monday
Now I want to get the value from the resource file but not using
string data = Resources.Text.Sun;
but using my enum value , I have found some code but I have an exception, the code is following :
string resourceFile = "~/App_GlobalResources/Text.resx";
string filePath = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(resourceFile, filePath, null);
string resourceValue = resourceManager.GetString(myEnum.ToString());
and I got the following Exception
Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: ~/App_GlobalResources/Text.resx locationInfo: fileName: ~/App_GlobalResources/Text.resx.resources
please help as soon as you can
Thanks in Advance
The resource is probably be a part of your assembly. Why don't you use the following? Resources.ResourceManager.GetString(test.Sun.ToString())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With