I am trying to replace path in given text file. I am using regular expression for that.
CodefilePath = txtFilePath.Text;
oldPath = txtOld.Text;
newPath = txtNew.Text;
string output = File.ReadAllText(filePath);
output = Regex.Replace(output, oldValue, newValue, RegexOptions.IgnoreCase);
File.WriteAllText(filePath, output);
I have tried oldPath.Replace(@"\\", @"\") also but now use.It throwing an exception like unrecognised escape sequence. Please let me know the solutions.


Abrar Ahmad AnsariRank #3,390 · 425 reputationPosted Jul 16, 2015, 10:51 PM EDT
Raja TRank #685 · 3.5K reputationPosted Jul 16, 2015, 10:59 PM EDT
Try this code
or use the @ symbol
SIVARank #2,303 · 613 reputationPosted Jul 17, 2015, 1:25 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jul 17, 2015, 3:19 AM EDT