Below is a sample code snippet that demonstrates how to read from a text file in C# .
How to Read from a Text File in C# ?
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.IO; namespace AbundantcodeConsoleApp { internal class Program { private static void Main(string[] args) { string ACFile = @"E:\input.txt"; using (System.IO.StreamReader Reader = File.OpenText(ACFile)) { var line = Reader.ReadLine(); Console.WriteLine(line); } Console.ReadLine(); } } }
Leave a Reply