If you read the text from the file into an array of strings (e.g. File.ReadAllLines() method), then you just need to do two Insert commands. Use a StringBuilder for your output text.
string[] lines = File.ReadAllLines("C:\\test.txt");
int pos1 = 9;
string insert1 = "<Math>";
int pos2 = 16 + insert1.Length;
string insert2 = "<Equation>";
StringBuilder output = new StringBuilder();
foreach(string s in lines)
{
string t = s.Insert(pos1, insert1);
output.Append(t.Insert(pos2, insert2));
}
// now write out output.ToString()
/- Sam Judson : Wrox Technical Editor -/
|