I'm trying to design a check on incoming strings for an array, and if the incoming string has a specific starting character it gets skipped over
For example:
;item1
item2
item3
;item4
should be put into array as
item2
item3
I thought I'd try to use a foreach method to skip the line that starts with the identifier, and then in the else append the lines that don't match back into the string array, but it doesn't seem I am able to do this.
Help!
void Whitelist()
{
if (logging == 1)
{
FIO._Log("Performing WhiteList func", writer);
}
try
{
string[] lines = File.ReadAllLines("Whitelist.ini");
string[] lines2;
foreach (string line in lines)
{
if (line.StartsWith(";"))
{
continue;
}
else
{
// lines2.append(line) ??
}
}
structs.CustomWhiteList = lines2;
}
catch (Exception e)
{
MessageBox.Show("Error reading whitelist file." + Environment.NewLine + e.Message);
FIO._Log("Failed to read whitelist file", writer);
}
}
lines2 = lines.Where(l => !l.StartsWith(";"));