Hi Peter,
Thank you for your reply!
I have spent more than one hour searching a .NET class library to merge RTF
files but without success.
In fact, a simple workaround is to use the RichTextBox control to do what
you want.
In detail,
1. Create two instances of RichTextBox in the application.
2. Call the RichTextBox.LoadFile method to load the first RTF file into the
first RichTextBox control.
3. Select and copy the content in the first RichTextBox control to
Clipboard by calling the SelectAll and Copy methods of the RichTextBox
class.
4. Paste the content from Clipboard to the second RichTextBox control by
calling the RichTextBox.Paste method.
5. Repeat the step2 to step4 to merge all the RTF files to the second
RichTextBox control.
6. Save the content in the second RichTextBox to a .RTF file by calling the
RichTextBox.SaveFile method.
The following is a sample:
private void MergeRTFFiles(string[] rtffiles, string outputfile)
{
RichTextBox richTextBox1 = new RichTextBox();
RichTextBox richTextBox2 = new RichTextBox();
foreach (string filepath in rtffiles)
{
if (File.Exists(filepath))
{
richTextBox1.LoadFile(filepath);
richTextBox1.SelectAll();
richTextBox1.Copy();
richTextBox2.Paste();
}
}
richTextBox2.SaveFile(outputfile);
richTextBox1.Dispose();
richTextBox2.Dispose();
richTextBox1 = null;
richTextBox2 = null;
}
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.