The easiest way to find and replace text in a file is to use the
Replace method of string as shown below.
string content= File.ReadAllText("FileName.txt");
text =
content
.Replace("find text", "replace text");
File.WriteAllText("
FileName
.txt", text);
You can use the
Regex.Replace method for more
complex replacements
Cheers,
Samitha
No comments:
Post a Comment