Here is my problem. I am sure it is probably something simple.
Say my listview has 6 items in it.
The problem I am running into is the whole last item #5 or 6 is not getting written out to the XML if I delete either #5 or 6 from the listview. If I delete item 1-4 it works fine. When I delete 5 or 6 then the whole last block does not get written out.
The way my XML file should work is item 1+2 contain the same info minus 3 fields so they are linked as one. They are all paired up 3+4 and 5+6 What should happen is if I delete #5 the XML should show 1+2, 3+4, and 5 alone.
Can someone tell me what I am doing wrong in this loop. I have been working on it for a while.
string PreviousRowArray = null;
foreach (ListViewItem row in listViewFount.Items)
string CurrentRow = "";
for (int i=0 ; i<row.SubItems.Count ;i++)
CurrentRow = CurrentRow + row.SubItems[i].Text + " ";
string CurrentRowArray = CurrentRow.Split(' ');
if (PreviousRowArray != null)
if ((CurrentRowArray.ToString() == PreviousRowArray.ToString()) &&
(CurrentRowArray.ToString() == PreviousRowArray.ToString()))
//Here I write out the CurrentRowArray information combined with
//the PreviousRowArray. Removed for ease of reading
PreviousRowArray = null;
CurrentRowArray = null;
//Here I write only the pervious line out to the
//XML file. Removed for ease of reading
PreviousRowArray = CurrentRowArray;
else//Move currentrow to previous
PreviousRowArray = CurrentRow.Split(' ');
//this is the end of the document