public static void Update()
        {
            string jsonfile = Directory.GetCurrentDirectory() + "\\config.json";
            if (File.Exists(jsonfile))
            {
                string jsonString = File.ReadAllText(jsonfile, Encoding.Default);//读取文件
                JObject jobject = JObject.Parse(jsonString);//解析成json
                jobject["Devices"]["name"] = "555555";//替换需要的文件
                string convertString = Convert.ToString(jobject);//将json装换为string
                File.WriteAllText(jsonfile, convertString);//将内容写进jon文件中
            }
            else
            {

            }
        }

 

config.json文件内容如下:

{
  "Name": "lotname",
  "Address": "wenzhou",
  "Devices": {
    "id": "001111",
    "name": "555555",
    "ip": "192.168.1.1"
  },
  "Doors": "4"
}