Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you programatically open a file in c# to append?
#1
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?
#2
If you want to simply write text by appending it to the existing file just create a new stream writer
Code:
StreamWriter sr = new StreamWriter("path to file", true);

Whent set to true it will append the text to the existing file. If the file does not exist the StreamWriter wil create a new file
Sssssssssoftware developer...


Forum Jump:


Users browsing this thread: 1 Guest(s)