C# 读取.resx资源文件写入到json文件中
//调用resxresourcereader类,需要引用system.windows.forms.dll,下同
resxresourcereader resxreader = new resxresourcereader(@"资源文件路径");
idictionaryenumerator dict = resxreader.getenumerator();
stringbuilder jsonbuilder = new stringbuilder("{\"th_th\": {");
while (dict.movenext())
{
console.writeline("{0},{1}", dict.key, dict.value);
jsonbuilder.append("\"" + dict.key + "\":\"" + dict.value + "\",\n");
}
var jsonstring = jsonbuilder.tostring().substring(0, jsonbuilder.length - 2) + "}}";
var path = directory.getcurrentdirectory();
file.writealltext(path + "/th_th.json", regex.unescape(jsonstring));
上一篇: 康熙最长寿的女儿:揭秘固伦恪靖公主的一生
下一篇: 持久的男人都被慢慢淘汰了