Tazin Khan
Tazin Khan

Reputation: 21

Writing in an existing file using streamwriter

I want to use StreamWriter to write in a file that already exists in my project's debug folder. How can I do that? I thought StreamWriter can only write to a whole new file.

Upvotes: 2

Views: 3273

Answers (2)

John Ryann
John Ryann

Reputation: 2393

Do you mean append?

 StreamWriter sw = new StreamWriter("abc.txt", true);
 sw.WriteLine("test");
 sw.Close();

Upvotes: 2

TGH
TGH

Reputation: 39278

using(var sw = new StreamWriter("yourfile.txt", true))//default location is your bin folder
{
}

Use the above overload

Upvotes: 0

Related Questions