HI can any one help me how to read from text file and append those in another text file.
File 1
line1
line2
line3
file2
line4
HI can any one help me how to read from text file and append those in another text file.
File 1
line1
line2
line3
file2
line4
This is a general solution that minimizes memory consumption which is good for working with very large files.
using(var writer = File.AppendText(@"path\to\file2.txt"))
{
foreach(var line in File.ReadLines(@"path\to\file.txt"))
{
writer.WriteLine(line);
}
}
See also File.AppendText
.