c# save and load listbox to file
string temp = AppDomain.CurrentDomain.BaseDirectory;
string sPath = Path.Combine(temp, "test.txt");
System.IO.StreamWriter SaveFile = new System.IO.StreamWriter(sPath);
foreach(var item in listBox1.Items)
{
SaveFile.WriteLine(item.ToString());
}
string line;
var file = new System.IO.StreamReader(sPath);
while ((line = file.ReadLine()) != null)
{
listBox1.Items.Add(line);
}