Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# read file line by line

using System;
using System.IO;
 
public class Example
{
    public static void Main()
    {
        string fileName = @"C:examplepath.txt";
 
        using (StreamReader streamReader = File.OpenText(fileName))
        {
            string text = streamReader.ReadToEnd();
            string[] lines = text.Split(Environment.NewLine);
 
            foreach (string line in lines) {
                Console.WriteLine(line);
            }
        }
    }
}
 
PREVIOUS NEXT
Tagged: #read #file #line #line
ADD COMMENT
Topic
Name
6+4 =