开发者

how to add text File2 content to the end of text file1

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜