/// <summary> /// 初始化 /// </summary> /// <param name="model"></param> public static string Init(TempModel model) { if (!Directory.Exists("App")) { Directory.CreateDirectory("App"); } if (!File.Exists("App/DNT.json")) { try { //throw new Exception("调试的时候手动抛出的异常~勿要慌"); File.WriteAllText("App/DNT.json", model.ObjectToJson(), Encoding.UTF8); } catch { return("初始化失败,请重新打开或者在App文件夹创建DNT.json\n内容如下:{\"CityId\":\"城市ID\"ConnStr\":\"数据库连接语句\"}"); } } return("初始化成功"); }
/// <summary> /// 初始化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Load(object sender, EventArgs e) { tempModel = GetModel(); }