0

Hello there, I've been busy nowadays with file manipulation and I've so far I've encountered a small problem in appending the contents of a file to another file. This is what I did:

string filename = @"C:\Temp.txt";
string body = null;
StreamReader sr = File.OpenText(files); 
body = sr.ReadToEnd();
StreamWriter sw = File.Create(filename);
sw.WriteLine(body);

sr = File.OpenText(files2);
body = sr.ReadToEnd();
File.AppendAllText(filename, body);

sw.Close();

It seems that I can't append the content of files2 to my Temp.txt file after placing the contents of files. Please help. Thanks.

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by murderotica
0

Hello again, it seems it is working. I will try it with more than two text files. Thank you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.