How to open file in append mode in c#

Total Post:135

C#  .NET 
 987  View(s)
Rate this:
Hi Everyone,
I want to create a file "Test.txt" and it will open in append mode.I am trying  many times but it is overwrite the previous data .So, please give me a solution. 
thank you.
  1. Post:135

    Re: How to open file in append mode in c#

    For create a file in append mode ,we need to use this constructor.

    StreamWriter file = new  StreamWriter(".../Text.txt", bool append);

    file.WriteLine("your text");

    if file are exist in specified path otherwise it will created a new one as well as it will start  write in append mode(if bool append is true otherwise file will be override ).


      Modified On Apr-11-2018 12:36:54 AM