我想使用资源文件来获取一些文本。这些资源文件将在dll中。本地化与万无一失,以防万一。我希望能够基于configsettings选择要使用的rexfile。
示例MyCompany.RexFiles.dll
我的问题鉴于在配置文件中,我有一个设置来决定使用哪个rexfile,例如CurrentRexfile =“ RexFileB”
我如何根据configSettings默认将rexFile设置为正确。
有什么建议么
您可以使用ResourceManager类检索资源:
System.Reflection.Assembly myAssembly = this.GetType().Assembly;
string rexFile = ConfigurationManager.AppSettings["CuurentRexfile"];
System.Reflection.Assembly otherAssembly = System.Reflection.Assembly.Load(rexFile);
System.Resources.ResourceManager resManager = new System.Resources.ResourceManager("ResourceNamespace.myResources", otherAssembly);
string test = resManager.GetString("resourceString");
在这里阅读更多
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句