Avatar image for complete
#1 Posted by complete (2 posts) - - Show Bio

How do you programatically open a file in c# to append?

I tried searching online for an example and so far I have not found anything.

There is System.IO.StreamWriter and there is System.IO.StreamReader but there is no StreamAppend. Is there some way to use StreamWriter without overwritting the content of the existing file? Is there some way to use System.IO.Stream with some sort of appending criteria?

Avatar image for asanfilippo
#2 Posted by asanfilippo (1 posts) - - Show Bio

The StreamWriter takes two parameters, the file name and append use the example below:

new StreamWriter("C:\MyFile.txt",true)