Have a look at the following code from MSDN library.
Cheers,
Denis
using System;
using System.IO;
class Test
{
public static void Main()
{
string path = @"c:\temp\MyTes t.txt";
// This text is added only once to the file.
if (!File.Exists(p ath))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText (path))
{
sw.WriteLine("H ello");
sw.WriteLine("A nd");
sw.WriteLine("W elcome");
}
}
// This text is always added, making the file longer over time
// if it is not deleted.
using (StreamWriter sw = File.AppendText (path))
{
sw.WriteLine("T his");
sw.WriteLine("i s Extra");
sw.WriteLine("T ext");
}
// Open the file to read from.
using (StreamReader sr = File.OpenText(p ath))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLi ne(s);
}
}
}
}
"Roy Gourgi" <ro***@videotro n.ca> wrote in message
news:Kn******** ***********@wag ner.videotron.n et...
Hi,
How could I append a text file to another text file. Let's say that I have
a File1 and I want to append File2 at the end of File1, how would I do that?
TIA
Roy