Hi Peter,
I have spent more than one hour searching a .NET class library to merge RTF
files but without success.
In fact, as Nirosh has suggested, 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.Loa dFile 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.Pas te 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.Sav eFile method.
The following is a sample:
private void MergeRTFFiles(s tring[] rtffiles, string outputfile)
{
RichTextBox richTextBox1 = new RichTextBox();
RichTextBox richTextBox2 = new RichTextBox();
foreach (string filepath in rtffiles)
{
if (File.Exists(fi lepath))
{
richTextBox1.Lo adFile(filepath );
richTextBox1.Se lectAll();
richTextBox1.Co py();
richTextBox2.Pa ste();
}
}
richTextBox2.Sa veFile(outputfi le);
richTextBox1.Di spose();
richTextBox2.Di spose();
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****@microsof t.com.
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.