It is likely you will have to pull the text file into memory and then do the replacements. You will then have to overwrite the file using the method you clearly know about. So you would first:
// Read lines from source file.
string[] arr = File.ReadAllLines(file);
YOu can then loop through and replace the text in the array.
var writer = new StreamWriter(GetFileName(baseFolder, prefix, num));
for (int i = 0; i < arr.Length; i++)
{
string line = arr[i];
line.Replace("match", "new value");
writer.WriteLine(line);
}
this method gives you some control on the manipulations you can do. Or, you can merely do the replace in one line
File.WriteAllText("test.txt", text.Replace("match", "new value"));
I hope this helps.