// Opens a file using File.OpenText and closes a file using Dispose()
static void ReadFile()
{
StreamReader reader = null;
try
{
reader = File.OpenText("d:\\file.txt");
if(reader.EndOfStream)
return;
Console.WriteLine(reader.ReadToEnd());
}
finally
{
if(reader != null)
reader.Dispose();
}
}
댓글 없음:
댓글 쓰기