System IO C# by API

using System;
using System.IO;
class MainClass
{
  static void Main(string[] args)
  {
    StreamWriter MyStream = null;
    string MyString = "Hello World";
    try
    {
      MyStream = File.CreateText("MyFile.txt");
      MyStream.Write(MyString);
    }
    catch (IOException e)
    {
      Console.WriteLine(e);
    }
    catch (Exception e)
    {
      Console.WriteLine(e);
    }
    finally
    {
      if (MyStream != null)
        MyStream.Close();
    }
  }
}