|
Hi,
I have a question: I am want to add text (many strings) into file by using the method TextWriter.Write(), will this method append text into a file or overwrite the content of file ?
Are there any other ways to append text into file ?
Thanks and regards,
|
|
|
|
|
A writer will write its content at the current file location, and move the current location to the end of the written content. In typical usage this means that it will append each time you call it.
|
|
|
|
|
Using a StreamWriter [^] is generally a better choice. When you open the underlying FileStream you can specify whether to append or not by the mode option[^].
|
|
|
|
|
The TextWriter don't care. The state of the underlying Stream is what matters -- it can be opened to append or overwrite.
|
|
|
|
|
Thanks all of you.
I used StreamWriter for this.
Kind regards,
|
|
|
|