I am trying to get data from web form and convert properties into a list of json objects through json.net, first time a list of object is stored in a file. But next time, instead of appending data into list it creates new list. So how can I add it in same list. Here is my code
public List<StudentProps> GetProps(StudentProps p)
{
List<StudentProps> s = new List<StudentProps>();
s.Add(p);
return s;
}
public void GetStudent(StudentProps p)
{
var json = JsonConvert.SerializeObject(GetProps(p), Formatting.Indented);
String FilePath = @"C:\Users\Haseeb\Desktop\Test.json";
File.AppendAllText(FilePath, json + Environment.NewLine);
var ReadFile = File.ReadAllText(FilePath);
// List<StudentProps> props = JsonConvert.DeserializeObject<List<StudentProps>>(ReadFile).ToList();
}