Skip to main content

๐Ÿ‘ฉโ€๐Ÿ’ป ่ฎ€ๆ–‡ๆช” ้€่กŒ่ฎ€ๅ–

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);
}
}

}
}

ref: C# ้€่กŒ่ฎ€ๅ–ๆ–‡ๅญ—ๆช”ๆกˆ | Dๆฃง - Delft Stack