I have a large string to read and it's always different, but one word is always the same. The word is MESSAGE
, so if my string reader comes across that word it has to write that whole string to disc. I did some code but it's not working, the if segment never triggers, what is wrong here?
string aLine;
StringReader strRead = new StringReader(str);
aLine = strRead.ReadLine();
if (aLine == "MESSAGE")
{
//Write the whole file on disc
}
You can change your code to work with Contains.
string aLine;
StringReader strRead = new StringReader(str);
aLine = strRead.ReadLine();
if (aLine.Contains("MESSAGE"))
{
//Write the whole file on disc
}