Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I just want to reload the list(of ) the next time I start the program.

How can I simply save and load multiple lists.

for example:
ListLoad (string FilePath, object List1);
ListSave (string FilePath, object List1);

What I have tried:

<pre>private List<Witnesses> SR = new List<Witnesses>();


<pre>public void ArraySave2(string filename, object obj)
{
File.WriteAllText(filename, JsonConvert.SerializeObject(obj));
}
public void ArrayRead2(string filename, object obj)
{
obj = JsonConvert.DeserializeObject<List>(File.ReadAllText(filename));
}
Posted
Updated 12-May-20 0:08am
v2

1 solution

You must wrap the list like this:
string json = JsonConvert.SerializeObject(new { List1 });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900