Hey guys,
So I've been trying to save a listview items to a txt file - since I'm not that experienced with any known database yet -, but it seems that I did something wrong somewhere in my code and it doesn't save the date. It does create the file, but no data inside. Here is my code:
So any suggestions guys?
So I've been trying to save a listview items to a txt file - since I'm not that experienced with any known database yet -, but it seems that I did something wrong somewhere in my code and it doesn't save the date. It does create the file, but no data inside. Here is my code:
try
{
StringBuilder sb = new StringBuilder();
StreamWriter sw = new StreamWriter("Log.txt");
if (logListView.Items.Count > 0)
{
foreach (ListViewItem lvi in logListView.Items)
{
foreach (ListViewItem.ListViewSubItem listViewSubItem in lvi.SubItems)
{
sb.Append(string.Format("{0}\t", listViewSubItem.Text));
}
sw.WriteLine(sb.ToString());
}
sw.WriteLine();
}
}
catch (Exception ex)
{
MessageBox.Show("Something went wrong, please try again!", "Error",MessageBoxButtons.OK ,MessageBoxIcon.Error);
}
So any suggestions guys?