Save listview to file

  • Thread starter Thread starter deciacco
  • Start date Start date
D

deciacco

I need some ideas on saving the contents of a listview to a file. C# 2
VS2k5.

Thanks.
 
Hi,

if you only the text of the listview content should be written to a file you
can use something like this:

StringBuilder listViewContent = new StringBuilder();

foreach (ListViewItem item in this.listViewControl.Items)
{
listViewContent.Append(item.Text);
listViewContent.Append(Environment.NewLine);
}

TextWriter tw = new StreamWriter("C:\\ListViewContent.txt");

tw.WriteLine(listViewContent.ToString());

tw.Close();
 
Back
Top