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.
Users Online
· Guests Online: 10
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
C# Program to Read All Lines using StreamReader
C# Program to Read All Lines using StreamReader
This is a C# Program to use streamreader to read entire line.
Problem Description
This C# Program Uses StreamReader to Read Entire Line.
Problem Solution
Here with the help of streamreader it reads and displays the entire line from the file.
Program/Source Code
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(); } } }
Program Explanation
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.
Runtime Test Cases
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.