I am reading a file in my winform and saving it in a list.i have a button "remove" and on clicking it an item (each list item is a line from the file) from the list is removeed and when i write back this list to a file the items i have removed are replaceed by a blank line.
I don't want these blank lines in my file. can anyone please tell me how to remove them.
I have tried using list.Remove(item)
to remove the item from the list.
here is what i have tried...
ListView.CheckedListViewItemCollection chkditems = listView1.CheckedItems;
Regex regex1 = new Regex(".*\"(?<vm_name>.*)\".*:.*{.*\"vmx_path\".*:.*r?\"(?<vmx_path>.*)\",.*\"vm_base\".*:.*r?\"(?<vm_base>.*)\".*");
List<string> list_to_items = new List<string>();
foreach (ListViewItem chkitem in chkditems)
{
foreach (string line in list)
{
Match match1 = regex1.Match(line);
if (match1.Success)
{
if (match1.Groups["vm_name"].Value == chkitem.Text)
{
list_to_items.Add(line);
}
}
}
listView1.Items.Remove(chkitem);
}
foreach (string tormv in index)
{
list.Remove(tormv);
}
for sample data for the list you can consider it containing any text.