public void stack()
{
string old;
string iniPath = Application.StartupPath + "list.ini";
bool isDeleteSectionFound = false;
List<string> deleteCodeList = new List<string>();
using (StreamReader sr = File.OpenText(iniPath))
{
while ((old = sr.ReadLine()) != null)
{
if (old.Trim().Equals("[DELETE]"))
{
isDeleteSectionFound = true;
}
if (isDeleteSectionFound && !old.Trim().Equals("[DELETE]"))
{
deleteCodeList.Add(old.Trim());
}
}
}
StringBuilder sb = new StringBuilder();
using (var reader = new StreamReader(File.OpenRead(textBox1.Text)))
{
//;
List<string> data = new List<string>();
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(' ');
if (values.Contains(deleteCodeList))// getting that error
continue;
//
data.Add(string.Join(" ", values));
}
}
File.WriteAllText(textBox1.Text, sb.ToString());
}
using System.IO;
using System.Linq;
static void Main(string[] args)
{
var reader = new StreamReader(File.OpenRead(@"C: est.ini"));
List<string> data = new List<string>();
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(' ');
if (values.Contains("REMOVE"))
continue;
//
data.Add(string.Join(" ",values));
}
//Inside data you have all the lines without the removed. You can rewrite
//to other file
}