Zi 字媒體
2017-07-25T20:27:27+00:00
C# 文字檔一行一行讀取
資料來源:https://msdn.microsoft.com/zh-tw/library/94223t4d….
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader(@”c:\test.txt”);
while((line = file.ReadLine()) != null)
{
System.Console.WriteLine (line);
counter++;
}
file.Close();
System.Console.WriteLine(“There were {0} lines.”, counter);
// Suspend the screen.
System.Console.ReadLine();
寫了
5860316篇文章,獲得
23313次喜歡