StreamWriter writes text files. It enables easy and efficient text output. It is best placed in a using-statement to ensure it is removed from memory when no longer needed. It provides several constructors and many methods.
This is a C# Program to use streamreader to read entire line.
This C# Program Uses StreamReader to Read Entire Line.
Here with the help of streamreader it reads and displays the entire line from the file.
Here is source code of the C# Program to Use StreamReader to Read Entire Line. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Use StreamReader to Read Entire Line */ using System; using System.IO; using System.IO.Compression; using System.Text; public sealed class Program { public static void Main() { Stream s = new FileStream(@"c:\sri\srip.txt", FileMode.Open); using (StreamReader sr = new StreamReader(s, Encoding.UTF8)) { string line; while ((line = sr.ReadLine()) != null) { Console.WriteLine(line); } Console.ReadLine(); } } }
This C# program is used to use StreamReader to read the entire line. It reads with the help of StreamReader, using while loop checks the line is not equal to null. If the condition is true, then execute the iteration of the loop. Print the entire line from the file.
StreamWriter writes text files. It enables easy and efficient text output. It is best placed in a using-statement to ensure it is removed from memory when no longer needed. It provides several constructors and many methods.