Give a Simple example of StreamReader class?

 Posted by vishalneeraj-24503 on 1/27/2014 | Category: C# Interview questions | Views: 2079 | Points: 40
Answer:

using System.IO;

string file_contents;
using (StreamReader sr = new StreamReader("C:\\rpt.txt"))
{
file_contents = sr.ReadLine();
}

if (!String.IsNullOrEmpty(file_contents))
{
MessageBox.Show(file_contents);
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response