日期:2014-05-18  浏览次数:20889 次

C#资源文件实现多语言
public   ResourceManager   GetCurrentCulture()
                {
                        Thread.CurrentThread.CurrentCulture   =   new   System.Globalization.CultureInfo( "zh-TW ");
                        ResourceManager   M   =   new   ResourceManager( "Resource1 ",   Assembly.GetAssembly(typeof(WindowsApplication6.Form1)));
                        return   M;
                }

                public   string   GetMessage(string   strID)
                {
                        string   CurrentLanguage   =   " ";

                        try
                        {
                                ResourceManager   RM   =   GetCurrentCulture();
                                CultureInfo   Info   =   new   CultureInfo( "zh-TW ",   true);

                                CurrentLanguage   =   RM.GetString(strID,Info);
                        }
                        catch
                        {
                                CurrentLanguage   =   "Cannt   Found   ,Please   Add   it   to   ResourceFile! ";
                        }
                        return   CurrentLanguage;
                }

实现界面汉字繁,简体.     资源文件名为Resource1.zh-TW.resx   和Resource1.zh-CN.resx,请问在程序中如何获取资源文件呢,困扰我一天的问题,请大家帮忙解决,谢谢!

------解决方案--------------------
ResourceManager M = new ResourceManager( "Resource1 ", Assembly.GetAssembly(typeof(WindowsApplication6.Form1)));
修改成
ResourceManager M = new ResourceManager( "你的项目名称.Resource1 ", Assembly.GetAssembly(typeof(WindowsApplication6.Form1)));

resource1要添加打工程里面