向现有资源文件添加值 [英] Adding Values to Existing Resource Files

查看:61
本文介绍了向现有资源文件添加值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将值列表添加到现有资源文件中
例如,在我的资源文件中,我有这样的键值对....

"resourceTestKey1"-"resourceTestValue1"
"resourceTestKey2"-"resourceTestValue2"
"resourceTestKey3"-"resourceTestValue3"
"resourceTestKey4"-"resourceTestValue4"

目前,我正在尝试使用以下代码向我的资源文件中添加另一个键值对

i am trying to add a list of values to my existing resource file
For example in my resource file i have key value pair like this....

"resourceTestKey1" - "resourceTestValue1"
"resourceTestKey2" - "resourceTestValue2"
"resourceTestKey3" - "resourceTestValue3"
"resourceTestKey4" - "resourceTestValue4"

Currently i am trying to add one more key value pair to my Resource File using below code

System.Resources.ResXResourceWriter resWriter = new System.Resources.ResXResourceWriter(this.resourceFilePath);                                
resWriter.AddResource("resourceTestKey5","resourceTestValue5");


现在,我所有的旧资源文件值都被删除了. 和资源文件仅包含此条目"resourceTestKey5","resourceTestValue5"

我如何通过保留当前值来添加新的资源键值对


Now all my old resource file values are deleted..
and resource file contains only this entry "resourceTestKey5","resourceTestValue5"

How can i add a new resource key value pair by retaining the current values

推荐答案

要创建.resx文件,请创建具有唯一文件名的ResXResourceWriter,调用AddResource至少调用一次Generate,将资源文件写入磁盘,然后调用Close来关闭文件.如果需要,调用Close将隐式生成文件.

希望对您有帮助
To create a.resx file, create a ResXResourceWriter with a unique file name, call AddResource at least once, call Generate to write the resources file to disk, and then call Close to close the file. Calling Close will implicitly Generate the file if required.

Hope it helps


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

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