In the C#, StreamWriter class in C# writes characters to a stream in a specified encoding which is inherits from TextWriter class. StreamWriter.Write() method is responsible for writing text.
C# StreamWriter example
using System;
using System.IO;
namespace FindAndSolve
{
public class Program
{
public static void Main(string[] args)
{ FileStream file = new FileStream("d:\\StreamWriterExample.txt", FileMode.Create);
StreamWriter objStream = new StreamWriter(file);
objStream.WriteLine("hello FindAndSolve");
objStream.Close();
file.Close();
Console.WriteLine("Your File has been created successfully...");
}
}
}
Output
Your File has been created successfully...