tags:

views:

112

answers:

1

How to save the ListView contents (including the ColumnHeaders) to a text file?

thanks.

+1  A: 

There is nothing in .NET that will do this for you, you need to do the work yourself.

On whatever event will trigger your save: open the file, iterate through the list content writing the text to the file and then close the file. The close can of course be done via using:

using (var tw = new StreamWriter(filename)) {
  foreach (ListViewItem item in listView.Items) {
    tw.WriteLine(item.Text); 
  }
}
Richard