2010年12月30日 星期四

讀取純文字檔

using System.IO;
private void ReadFile(string fileName)
{
string line;
try
{
//Create an instance of StreamReader to read from a file.
using (StreamReader  sr= new StreamReader (fileName))
{
while(sr.Peek ()>-1)
{
line=sr.ReadLine();
}
}
}
catch (Exception Ex)
{
Console.WriteLine(Ex.Message);
}
}

沒有留言: