C# program to shows how to use the StreamWriter class to append data.

Category > CSHARP || Published on : Tuesday, October 20, 2020 || Views: 684 || StreamWriter class to append data


Here Pawan Kumar will explain how to to use the StreamWriter class to append data.

using System;
using System.IO;
namespace Demo {
  class Program {
    // The main function
    static void Main(string[] args) {
      // Opening the file in append mode
      StreamWriter src = new
      StreamWriter(@"C:\Test.html", true);
      // Writing contents to the file
      src.WriteLine("Hello World");
      Console.Read();
    }
  }
}