Saturday, 2 December 2017

C# Program to Perform Text Operations in a File


Code:

using System;
using System.IO;
class Program
{
    static void Main()
    {
        FileInfo finfo = new FileInfo("C:\\sri\\srip.txt");
        using (StreamWriter writer = finfo.AppendText())
        {
            writer.WriteLine("New File with various Text operations");
        }
        finfo = new FileInfo("C:\\sri\\srip.txt");
        using (StreamWriter writer = finfo.CreateText())
        {
            writer.WriteLine("New File with various Text operations");
        }
        using (StreamReader reader = finfo.OpenText())
        {
            Console.WriteLine(reader.ReadToEnd());
        }
        Console.Read();
    }
}


Output:

New File with various Text operations


More C# Programs:


















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...