How to replace text in this situation?
-
Using the code below, I am trying to find the text
but when I view what my program is seeing, it is actually seeing
<add key=\"GetListDefaultResultSize\" value=\"6500\" />
How do I adjust for the escape characters that are added before the quotes when my code does a File.ReadAllText?
string allFileText = File.ReadAllText(networkFilePath);
if (allFileText.Contains(replacementLine))
{
lvwAppendFiles.Items.Add(networkFilePath + " contains " + replacementLine);
}
else
{
lvwAppendFiles.Items.Add(networkFilePath + " does NOT contain " + replacementLine);
} -
Using the code below, I am trying to find the text
but when I view what my program is seeing, it is actually seeing
<add key=\"GetListDefaultResultSize\" value=\"6500\" />
How do I adjust for the escape characters that are added before the quotes when my code does a File.ReadAllText?
string allFileText = File.ReadAllText(networkFilePath);
if (allFileText.Contains(replacementLine))
{
lvwAppendFiles.Items.Add(networkFilePath + " contains " + replacementLine);
}
else
{
lvwAppendFiles.Items.Add(networkFilePath + " does NOT contain " + replacementLine);
} -
Using the code below, I am trying to find the text
but when I view what my program is seeing, it is actually seeing
<add key=\"GetListDefaultResultSize\" value=\"6500\" />
How do I adjust for the escape characters that are added before the quotes when my code does a File.ReadAllText?
string allFileText = File.ReadAllText(networkFilePath);
if (allFileText.Contains(replacementLine))
{
lvwAppendFiles.Items.Add(networkFilePath + " contains " + replacementLine);
}
else
{
lvwAppendFiles.Items.Add(networkFilePath + " does NOT contain " + replacementLine);
}If you are looking at the string in the debugger, it is the debugger that is adding the escape characters to what it is displaying, they aren't actually in the string. The easy way to verify this is to check the Length of the string. It should not include the escape characters in the count.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed." - G.K. Chesterton