How to ignore blank lines from TextFile when they are between and after the lines?
TextFile format:
2016-01-01 20:23;Work;5;чистка;5000.00 2016-01-03 00:40;Custom;1;2;6;3 2016-01-03 00:41;Custom;1;1;10;1 48 line if (element[1] == "Card")
But the code itself:
public void SplitAndQuery(string path) { char[] separatorLines = { '\n' }; char[] separatorWords = { ';' }; string[] lines = File.ReadAllText(path, Encoding.Default).Split(separatorLines, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i <= lines.Length - 1; i++) { string[] element = lines[i].Split(separatorWords, StringSplitOptions.RemoveEmptyEntries); if (element[1] == "Card") { if (checkCard(element[2]) == false) { insertCard(element[2], element[3], element[4], element[5], element[6], element[7], element[8]); if (checkDiscount(element[2]) == "-1") { connection.Close(); MessageBox.Show("ups"); } else { insertDiscount(element[0],element[9]); } } else if (checkCard(element[2]) == true) { updateCard(element[3], element[4], element[5], element[6], element[7], element[8], element[2]); if (checkDiscount(element[2]) == "-1") { connection.Close(); MessageBox.Show("ups"); } else { insertDiscount(element[0],element[9]); connection.Close(); } } }
char[] separatorLines = { '\r', '\n' };- Dmitry