find and solve || findandsolve.com
Please wait.....

How to use C# Textreader Class

C# Textreader and TextWriter are the another way to read and write file respectively which is the abstract base class of StreamWriter and StringWriter.It is used to write text or sequential series of characters into file.

C# TextWriter Example

using System;  
using System.IO;
namespace TextWriterExample
{
    public class Program
    {
        public static void Main(string[] args)         {
            using (TextWriter writer = File.CreateText("d:\\test.txt"))
            {                 writer.WriteLine("Hello FindAndSolve");
                writer.WriteLine("C# File Handling by findandsolve");
            }
            Console.WriteLine("Data written successfully...");
        }
    }
}

Output

Data written successfully...

test.txt:

Hello FindAndSolve

C# File Handling by findandsolve