如何在运行时重新使用文件? [英] how to resx file use at run time?

查看:88
本文介绍了如何在运行时重新使用文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还有另一个问题
我现在将转换为resx文件中的所有表单如何在用户选择特定语言时安装时使用所有resx文件,因为我的应用程序中有20个表单,因此我们可以为此传递每个resx文件吗?

I have another qus
i converted all the form in resx file now how to use all resx file at intallation time when user select a particular language becaz i have 20 forms in my application so can we pass each resx file for that?

推荐答案

首先,您需要定义CultureInfo,可以使用系统值,也可以单独定义它; ​​
First you need to define the CultureInfo, you can either use the system value or define it separately;
CultureInfo currentCulture = Thread.CurrentThread.CurrentUICulture; //Defined by the system
CultureInfo currentCulture = new CultureInfo("fr-FR"); //Manually Defined French Language



您需要一个资源管理器,以根据CultureInfo从正确的resx文件中获取值.
现在假设您的应用程序名为MyApp,并且resx文件的默认值为MessageResource



The you need a resource manager to get the values from the correct resx file based on the CultureInfo.
Now assume your application is called MyApp and the resx file default is MessageResource

ResourceManager resourceManager = new ResourceManager("MyApp.MessageResource", System.Reflection.Assembly.GetExecutingAssembly());



然后使用正确的值,例如名为"ExitMessage"的字符串;



Then to get the correct value such as a string called "ExitMessage" you use;

resourceManager.GetString("ExitMessage", currentCulture)


这篇关于如何在运行时重新使用文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆