srikanth kamuju

srikanth kamuju

  • NA
  • 2
  • 1.7k

Editing text in a file apostrophe is replaced with another

May 29 2013 8:40 AM
Dear All,

While editing the the text file the apostrophe (') is replacing with another character automatically. i dont want to be replaced it. See the below code for review.

StringBuilder newFile = new StringBuilder();
string temp = "";
string[] AllLines = File.ReadAllLines(FileName);
strStart = "<";
foreach (string strLine in AllLines)
{
if (strLine.Contains("CUsers") || strLine.Contains("_ags"))
{
fIndex = strLine.IndexOf(strStart);
sIndex = strLine.LastIndexOf("_ags");
temp = strLine.Remove(fIndex + 2, (sIndex - fIndex) + 2);
newFile.Append(temp + "\r\n");
continue;
}
newFile.Append(strLine + "\r\n");
}
File.WriteAllText(FileName, newFile.ToString());


Could any one please help me with code need urgent


Thanks in advance,
Srikanth

Answers (2)