Ami*_*ail 6 c# resources enums
我有一个包含一些数据的枚举,我也有一个资源文件,其中包含相同的枚举数据但使用不同的翻译
防爆.
enum test
{
Sun =1,
Mon = 2
}
The resource file : Text.resx
Sun --> Sunday
Mon --> Monday
Run Code Online (Sandbox Code Playgroud)
现在我想从资源文件中获取值但不使用
string data = Resources.Text.Sun;
Run Code Online (Sandbox Code Playgroud)
但是使用我的枚举值,我找到了一些代码,但我有一个例外,代码如下:
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());
Run Code Online (Sandbox Code Playgroud)
我得到以下例外
找不到适合磁盘上指定文化(或中性文化)的任何资源.baseName:〜/ App_GlobalResources/Text.resx locationInfo:fileName:〜/ App_GlobalResources/Text.resx.resources
请尽快帮忙
提前致谢