private void writeone() { EMAValue_Json sb = new EMAValue_Json(); sb.NumVal = "500"; List <EMAValue_Json> list = new List <EMAValue_Json>(); list.Add(sb); string convertedJson = JsonConvert.SerializeObject(list, Formatting.Indented); File.AppendAllText(@"C:\temp\EMALog_json.txt", convertedJson); }
private void writeoutlast(decimal value) { string sinFromEmaLog = ""; sinFromEmaLog = File.ReadAllText(@"C:\temp\EMALog_json.txt"); var list = JsonConvert.DeserializeObject <List <EMAValue_Json> >(sinFromEmaLog); EMAValue_Json itemToAdd = new EMAValue_Json(); itemToAdd.NumVal = value.ToString(); list.Add(itemToAdd); string convertedJson = JsonConvert.SerializeObject(list, Formatting.Indented); File.WriteAllText(@"C:\temp\EMALog_json.txt", convertedJson); }