using System;
using System.IO;
namespace FileIOText
{
class ReadTextFile
{
public ReadTextFile()
{
try
{
//-- "using" also closes the file
using (StreamReader sr = new StreamReader("data.txt"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
catch(Exception e){
Console.WriteLine("File could not be read");
Console.WriteLine(e.Message);
}
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment