ResourceWriter 数据格式化
我有一个 .resx 文件来更新一些数据。 我可以通过 ResXResourceSet 对象从文件中读取数据,但是当我想将数据保存回来时,保存的数据格式是 无法辨认。 如何编辑 .resx
文件? 谢谢。
ResXResourceSet st = new ResXResourceSet(@"thepath");
entries=new List<DictionaryEntry>();
DictionaryEntry curEntry ;
foreach (DictionaryEntry ent in st)
{
if (ent.Key.ToString() == "Page.Title")
{
curEntry = ent;
curEntry.Value = "change this one"
entries.Add(curEntry);
}
else
{
entries.Add(ent);
}
}
st.Close();
System.Resources.ResourceWriter wr = new ResourceWriter(@"thepath");
foreach (DictionaryEntry entry in entries)
{
wr.AddResource(entry.Key.ToString(), entry.Value.ToString());
}
wr.Close();
I have a .resx
file to update some data. I can read the data from the file via a ResXResourceSet
object, but when I want to save the data back, the saved data format is
unrecognizable. How do I edit .resx
files? Thanks.
ResXResourceSet st = new ResXResourceSet(@"thepath");
entries=new List<DictionaryEntry>();
DictionaryEntry curEntry ;
foreach (DictionaryEntry ent in st)
{
if (ent.Key.ToString() == "Page.Title")
{
curEntry = ent;
curEntry.Value = "change this one"
entries.Add(curEntry);
}
else
{
entries.Add(ent);
}
}
st.Close();
System.Resources.ResourceWriter wr = new ResourceWriter(@"thepath");
foreach (DictionaryEntry entry in entries)
{
wr.AddResource(entry.Key.ToString(), entry.Value.ToString());
}
wr.Close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗨,我再次搜索并发现..ResourceWriter
将数据写入二进制类型
ResourceReader 以二进制类型读取数据
ResXResourceWriter 以 xml 格式写入数据
ResXResourceReader 以 xml 格式读取数据
,因此上面的示例使用 ResXResourceWriter,ResXResourceReader 而不是 ResourceReader,ResourceWriter 将以 xml 类型操作资源
Hi again i searched up and found that..
ResourceWriter writes data as binary type
ResourceReader reads data as binary type
ResXResourceWriter writes data as xml format
ResXResourceReader reads data as xml format
so example on top using ResXResourceWriter,ResXResourceReader instead of ResourceReader ,ResourceWriter will manipulate resources as xml type