Read a string stored in a resource file (resx) with dynamic file name

后端 未结 4 1784
感情败类
感情败类 2021-02-14 14:12

In my C# application I need to create a .resx file of strings customized for every customer.

What I want to do is avoid recompiling the entire project every time I have

4条回答
  •  耶瑟儿~
    2021-02-14 14:14

    Will something like this help in your case?

    Dictionary resourceMap = new Dictionary();
    
    public static void Func(string fileName)
    {
        ResXResourceReader rsxr = new ResXResourceReader(fileName);        
        foreach (DictionaryEntry d in rsxr)
        {
            resourceMap.Add(d.Key.ToString(),d.Value.ToString());           
        }        
        rsxr.Close();
    }
    
    public string GetResource(string resourceId)
    {
        return resourceMap[resourceId];
    }
    

提交回复
热议问题