Tuesday, 16 June 2020

Read the Text file and print the Data using Console Application

C# Code for Read the data and print the data on console window.
Console application for print the data from the text file using the C# console application in Microsoft Visual Studio IDE.

//Program.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading.Tasks;

namespace Readfile
 {
   class Program
     {
       static void Main(string[],args)
         {
                  string textfile = System.IO.File.ReadAllText(@"C:\Users\textfile.txt");

            Console.WriteLine("text file is {0} ",textfile);

                         string textfilelines = System.IO.File.ReadAllLines(@"C:\Users\textfile.txt");
                       foreach(string lines in textfilelines )
                   {
                               Console.WriteLine("lines are\t",lines);
                   }
               Console.WriteLine("press any key to continue..");
               Console.ReadKey();
}






                           

0 comments:

Post a Comment