在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
0.json文件 { "CAN": false, "AccCode": 4294901856, "Id": 768, "BPointMove": true, "L_BPointMoveDelay": "600", "R_BPointMoveDelay": "1000" }
1.Read try { StreamReader file = File.OpenText("config.json"); JsonTextReader reader = new JsonTextReader(file); JObject jsonObject = (JObject)JToken.ReadFrom(reader); CAN_Communication = (bool) jsonObject["CAN"]; AccCode = (uint) jsonObject["AccCode"]; Id = (uint) jsonObject["Id"]; // Configure Json BPointMove = (bool)jsonObject["BPointMove"]; _classLeft.DelayBPointMove = (int)jsonObject["L_BPointMoveDelay"]; _classRight.DelayBPointMove = (int)jsonObject["R_BPointMoveDelay"]; file.Close(); } catch { //MessageBox.Show("CAN卡配置有误!"); } 2.Write try { string json = File.ReadAllText("config.json"); dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json); jsonObj["L_BPointMoveDelay"] = LBPointdelay.ToString(); string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented); File.WriteAllText("config.json", output); } catch { }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论