The first thing you have to import the namespace System.IO.
then create a object for Stream reader class and mention the path of text file
. then by using objectname.ReadToEnd we can display the content of the text
file.
Suppose in d drive you have a folder called examples .
Inside the examples folder you have a text file called show.txt.
Content of show.txt is:
Program:
using System;
using System.IO;
namespace TextFileReader
{
class Program
{
static void Main(string[] args)
{
StreamReader str = new StreamReader(@"D:\examples\show.txt");
Console.WriteLine(str.ReadToEnd());
Console.ReadLine();
}
}
}
Output:
-----Muthu karthikeyan.Madurai
No comments:
Post a Comment