public class Class1
{
private const string FILE_NAME="MyFile.txt";
public static void Main(String[] args)
{
if(!File.Exists(FILE_NAME)) //如果不文件存在,则抛出异常
{
Console.WriteLine("{0} does not exist!",FILE_NAME);
}
StreamReader sr=File.OpenText(FILE_NAME);
String input;
while((input=sr.ReadLine())!=null)
{
Console.WriteLine(input);
}
Console.WriteLine("The end of the Stream has been reched.");
sr.Close();
}
}