10-20-2011، 06:15 PM
[c#] save a listbox to file
Code:
Code:
کد:
> public void saveConfig(ListBox list)
{
try
{
writer = new StreamWriter(Application.StartupPath + "my.filename.goes.here");
for (Int32 i = 0; i < list.Items.Count; i++)
{
writer.WriteLine(list.Items[i].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
writer.Close();
}
}