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