Its bit Tricky. I am trying to give you just the basic idea.
- Just write &&&& at the end of every page. In English doc as well as in Spanish doc.
- now use regex to break text from &&&&. Its like reading the doc page by page.
Here is a sample code just to give you the basic logic.
string Doc1Read = //read from english file
string Doc2Read = // read from Spanish file
string exp = @"[\w\s\n\r\t\.\(\)\,\[\]\-\;\:\%\@\#]*(?=&&&&)";
var Doc1matches = Regex.Matches(Doc1Read, exp);
var Doc2matches = Regex.Matches(Doc2Read, exp);
for (int i = 0; i < Doc1matches.Count; i++)
{
**// open third document file and write**
Doc1matches[i].Value; // write english version of page i
Doc2matches[i].Value; // write spanish version of page i
}
&&&& is used to get the text page by page . In this way when you use Doc1matches[i].Value;
you basically get what is written on page number i i.e {1,2,3...}.
Hope it helped you.
PS : You can also use string.Split("&&&&");
to break the string from &&&&. and can implement the logic.