fix bug 11071900

Signed-off-by: lilium-saber <WR364999428@hotmail.com>
GDN
lilium-saber 1 year ago
parent 99f5d11070
commit 80799ae956

@ -25,18 +25,23 @@ namespace WpfApp2
public TempResource() //用于创建 public TempResource() //用于创建
{ {
if(Directory.Exists(jsonpath)) if(!Directory.Exists(jsonpath))
{ {
List<MyData> js = JsonConvert.DeserializeObject<List<MyData>>(jsonpath); StreamWriter streamWriter = new StreamWriter(jsonpath);
js.Add(new MyData() { ID = "20230923001827495", KEY = "yjvMNY33Qc1TYSBjTQYQ", SECRET = "M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk", SRCLAN = "jp", DSTLAN = "zh", NOW = "baidu", } ); streamWriter.WriteLine("{\n\"ID\" : \"20230923001827495\"," +
string jjson = JsonConvert.SerializeObject(js); "\n\"KEY\" : \"yjvMNY33Qc1TYSBjTQYQ\"," +
File.WriteAllText(jsonpath, jjson); "\n\"SECRET\" : \"M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk\"," +
"\n\"SRCLAN\" : \"jp\"," +
"\n\"DSTLAN\" : \"zh\"," +
"\n\"NOW\":\"baidu\"\n" +
"}");
streamWriter.Close();
} }
} }
private MyData GetJsonStream() private MyData GetJsonStream()
{ {
string jsonF = File.ReadAllText(jsonpath); var jsonF = File.ReadAllText(jsonpath);
MyData da = JsonConvert.DeserializeObject<MyData>(jsonF); MyData da = JsonConvert.DeserializeObject<MyData>(jsonF);
return da; return da;
} }

@ -1,10 +1,5 @@
 using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApp2.translationKey namespace WpfApp2.translationKey
{ {
@ -24,19 +19,21 @@ namespace WpfApp2.translationKey
string temppathTemp = pathTemp + "\\" + name + ".txt"; string temppathTemp = pathTemp + "\\" + name + ".txt";
StreamWriter sw = new StreamWriter(temppathTemp); StreamWriter sw = new StreamWriter(temppathTemp);
StreamWriter sw2 = new StreamWriter(txtPath,true);
foreach (string s in list) foreach (string s in list)
{ {
sw.WriteLine(s); sw.WriteLine(s);
} }
name = "\n" + name;
System.IO.File.AppendAllText(txtPath, name);
sw2.WriteLine(name);
sw.Close(); sw.Close();
sw2.Close();
} }
public void InputBaiduPrivate(string name, string id, string key)//该函数仅百度支持 public void InputBaiduPrivate(string name, string id, string key)//该函数仅百度支持
{ {
if(!Directory.Exists(pathTemp)) if (!Directory.Exists(pathTemp))
{ {
Directory.CreateDirectory(pathTemp); Directory.CreateDirectory(pathTemp);
} }
@ -44,10 +41,10 @@ namespace WpfApp2.translationKey
string temppathTemp = pathTemp + "\\" + name + ".txt"; string temppathTemp = pathTemp + "\\" + name + ".txt";
StreamWriter sw = new StreamWriter(temppathTemp); StreamWriter sw = new StreamWriter(temppathTemp);
StreamWriter sw2 = new StreamWriter(txtPath); StreamWriter sw2 = new StreamWriter(txtPath);
InputTranslationId(id,sw); InputTranslationId(id, sw);
InputTranslationKey(key,sw); InputTranslationKey(key, sw);
sw2.WriteLine(name); sw2.WriteLine(name);
sw.Close(); sw.Close();
sw2.Close(); sw2.Close();

Loading…
Cancel
Save