C# program to show the way to use the StreamWriter class

Category > CSHARP || Published on : Monday, October 19, 2020 || Views: 56 || StreamWriter class


Here Pawan Kumar will explain how to show the way to use the StreamWriter class

Implements a TextWriter for writing characters to a stream in a particular encoding.

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");
      // Writing contents to the file
      src.WriteLine("Hello World");
      Console.Read();
    }
  }
}