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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM