๐ฉโ๐ป ่ฎๆๆช ้่ก่ฎๅ
1. File.ReadAllLinesโ
File.ReadAllLines(FileName);
2. ReadLine()โ
//We have to create Streader Object to use this method
StreamReader ObjectName = new StreamReader(FileName);
ObjectName.ReadLine();
using System;
using System.IO;
public class ReadFile
{
public static void Main()
{
string FileToRead = @"D:\New folder\textFile.txt";
using (StreamReader ReaderObject = new StreamReader(FileToRead))
{
string Line;
// ReaderObject reads a single line, stores it in Line string variable and then displays it on console
while((Line = ReaderObject.ReadLine()) != null)
{
Console.WriteLine(Line);
}
}
}
}