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));