hello i had this code and it worked well:
private void Textparsing()
{
using (StreamReader sr = new StreamReader(Masterbuildpropertiespath))
{
while (sr.Peek() >= 0)
{
if (sr.ReadLine().StartsWith("Exec_mail"))
{
ExecmailCheckBox.IsChecked = true;
}
if (sr.ReadLine().StartsWith("Exec_text"))
{
ExectextCheckBox.IsChecked = true;
}
if (sr.ReadLine().StartsWith("Exec_3"))
{
Exec3CheckBox.IsChecked = true;
}
if (sr.ReadLine().StartsWith("Exec_4"))
{
Exec4CheckBox.IsChecked = true;
}
}
}
}
It was perfect and i got all the 4 checkbox checked when i got the correct text in the file.
However, I am receiving Nullreference error over at this line:
if (sr.ReadLine().StartsWith("Exec_text"))
{
ExectextCheckBox.IsChecked = true;
}
When test it out for 1 target(means i make the other 3 targets as comments), it all worked fine. Please advice
With the evaluation of EACH if statement a line is being read. Better is to read the line and then have the multiple ifs: