i have 2 files that contain text, file1 and file2
i need to add the content of file2 to file1
fi开发者_如何学JAVAle1
=====
111
222
333
file2
=====
444
555
666
after the add file1 will look like this:
111
222
333
444
555
666
File.AppendAllText("file1.txt", Environment.NewLine + File.ReadAllText("file2.txt"));
Using below code :
StreamReader sr = new StreamReader(filePath2);
string fileString = sr.ReadToEnd();
sr.Close();
StreamWriter sw = new StreamWriter(filePath1,true);
sw.WriteLine(fileString);
sw.Close();
精彩评论