Home   Cover Cover Cover Cover
 

finally

A06.cs
using System;
using System.IO;

class Test {
  
  static void Print(string path) {
    if (File.Exists(path))
      Console.Write(File.GetCreationTime(path));
  }
  
  static void Main(string[] arg) {
    Console.WriteLine("start");
    TextWriter oldOut = Console.Out;
    StringWriter w = new StringWriter();
    Console.SetOut(w);
    try {
      Print(arg[0]);
    } finally {
      Console.SetOut(oldOut);
    }
    Console.WriteLine(w.ToString());
    Console.WriteLine("done");
  }
  
}