How to add a line to already existing file with StreamWriter? I Tried doing researches but nothing fits my needs.
I have this:
using (StreamWriter writer = new StreamWriter(appdata + @"\FILE.txt"))
{
writer.WriteLine(Environment.NewLine + "newline");
}
And instead of replacing the text that is in the file I want to add a new line to it. Also, if the file doesn't exist, it should create itself. This code does in fact what I described, but it replaces (so for example if you click once it's newline
and then again it's just newline2
. newline
is not there. It should look like:
newline
<
I want this effect
newline2
<
and then add more after a new line.