By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,812 Members | 1,647 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,812 IT Pros & Developers. It's quick & easy.

Appending multiple RTF file into one

P: 49
Can anyone help me out in this? I want to append multiple RTF file into one RTF file. I tried using 'streamwriter', the resulting file size becomes big and when i open it, it is the original i.e the first RTF file only and not the appended one. But i open the file with notepad it looks appended. I've supplied my code below . I've searched thru internet a lot but didn't get anything. So if anybody hav a solution plz help me out.

I'll explain something 'bout the code.
File in path1 is a new blank file i.e to b created.
File in path2 and path3 have contents.

using system;
using system.IO;

try
{
string path1 = @"C:\amit.rtf";
string path2 = @"C:\T0000072.rtf";
string path3 = @"C:\T0000073.rtf";
FileStream file2 = new FileStream(path2, FileMode.OpenOrCreate, FileAccess.ReadWrite);
FileStream file3 = new FileStream(path3, FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamReader sr2 = new StreamReader(file2);
StreamReader sr3 = new StreamReader(file3);
string s = sr2.ReadToEnd();
string s1 = sr3.ReadToEnd();
StreamWriter sw1 = new StreamWriter(path1);
sw1.WriteLine(s);
sw1.WriteLine(s1);
sw1.Close();
sr2.Close();
sr3.Close();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
Dec 11 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.