动态将值添加到资源(C#) [英] dynamically add values to resources (C#)

查看:81
本文介绍了动态将值添加到资源(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过编码(C#)向资源动态添加值.我的下面的代码运行没有任何错误,但是这些值未添加到资源文件中.

I want to add values to the resources dynamically through codings(C#). My below coding runs without any error but the values are not getting added to the resource file.

protected void Button2_Click(object sender, EventArgs e)
{
    using (ResXResourceWriter resx = new ResXResourceWriter("Resources.resx"))
    {
        resx.AddResource( "joth", "joth");
        resx.Close();
    }
}      

推荐答案

protected void Button2_Click(object sender, EventArgs e)
{
    using (ResXResourceWriter resx = new ResXResourceWriter("Resources.resx"))
    {   resx.AddResource( "joth", "joth");
        resx.Save();
        resx.Close();
    }
} 

这篇关于动态将值添加到资源(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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