C# program to copy the content of one file to another file

Program

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            string data;

            data = File.ReadAllText("ABC.TXT");
            Console.WriteLine("Content of ABC.TXT :\n"+data);

            File.Copy("ABC.TXT", "XYZ.TXT");

            data = File.ReadAllText("XYZ.TXT");
            Console.WriteLine("Content of XYZ.TXT :\n" + data);

        }
    }
}

Output

Content of ABC.TXT :
India is a great country.
Content of XYZ.TXT :
India is a great country.

Leave a Comment

error: Alert: Content is protected!!