我有一个枚举类型,其中包含一些数据,同时我还有一个资源文件,其中包含相同的枚举数据,但使用不同的翻译。
现在我想从资源文件中获取值,但不想使用。
但是使用我的枚举值,我找到了一些代码,但出现了异常,代码如下:
我得到了以下异常:
找不到适合指定区域性(或中性区域性)的任何资源。基本名称: ~/App_GlobalResources/Text.resx位置信息:文件名: ~/App_GlobalResources/Text.resx.resources
请尽快提供帮助。
提前致谢。
enum test
{
Sun =1,
Mon = 2
}
The resource file : Text.resx
Sun --> Sunday
Mon --> Monday
现在我想从资源文件中获取值,但不想使用。
string data = Resources.Text.Sun;
但是使用我的枚举值,我找到了一些代码,但出现了异常,代码如下:
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());
我得到了以下异常:
找不到适合指定区域性(或中性区域性)的任何资源。基本名称: ~/App_GlobalResources/Text.resx位置信息:文件名: ~/App_GlobalResources/Text.resx.resources
请尽快提供帮助。
提前致谢。