2012年9月4日 星期二

c# read file


Reference

using System.IO;

Add function to source code

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

沒有留言: