I want to ask how to combine two text file and read in the rich text box..?
String rd = "";
private void CLICK2_Click(object sender, EventArgs e)
{
string file1 = @"C:\Users\Fish\Desktop\fyp-coding\sample1.txt";
string file2 = @"C:\Users\Fish\Desktop\fyp-coding\sample2.txt";
FileStream fs1 = null;
FileStream fs2 = null;
try
{
fs1 = File.Open(file1, FileMode.Append);
fs2 = File.Open(file2, FileMode.Open);
byte[] fs2Content = new byte[fs2.Length];
fs2.Read(fs2Content, 0, (int)fs2.Length);
fs1.Write(fs2Content, 0, (int)fs2.Length);
if (File.Exists(file1))
{
StreamReader rfile = null;
try
{
rfile = new StreamReader(file1);
while ((rd = rfile.ReadLine()) != null)
{
s4.AppendLine(rd);
}
showFile2.AppendText(s4.ToString().Trim());
}
finally
{
rfile.Close();
}
}
This is my coding..I need to show the new content after combine two files in the rich text box.Hope someone can help me..thanks