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
Loading
Pankaj PandeyPosted May 29, 2013, 9:04 AM
may be it will help you
StringBuilder newFile = new StringBuilder();
string temp = "";
string[] AllLines = File.ReadAllLines(FileName);
strStart = "<";
foreach (string strLine in AllLines)
{
if (strLine.Contains("CUsers") || strLine.Contains("_ags"))
{
//strLine=strLine.Replace("Your character"," replacing character");
strLine=strLine.Replace("<","'"); //apostrophe
continue;
}
newFile.Append(strLine + "\r\n");
}
File.WriteAllText(FileName, newFile.ToString());
if helpful then mark as answered.
VulpesPosted May 29, 2013, 9:03 AM