C# 讀取resource文件


            ResourceManager fileText = null;
            string path = "ResourceCon.test.Language";
            fileText = new ResourceManager(path, typeof(Test).Assembly);
            string res = fileText.GetString("PortalSettingKey_hisBoxFocus", new CultureInfo("en")); //new CultureInfo("zh-CN")

上面代碼中ResourceCon為類庫名。Test為類庫下的一個文件。需要在類庫下建一個test文件夾。放置兩個資源文件ResCon.test.Language.resources和ResCon.test.Language.zh-CN.resources

 

ResourceManager構造函數表示在集合里查找含有path名稱的resource文件
GetString方法表示指定語言查找key對應值


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM