using System;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Collections.Generic;
using System.Text;

namespace MoreTrustedAssembly
{
   public class Class1
   {
      public void CreateFile()
      {
         try
         {
            FileIOPermission filePerm = new FileIOPermission(
               FileIOPermissionAccess.Write,
            AppDomain.CurrentDomain.BaseDirectory);

            filePerm.Demand();

            FileStream fs = new FileStream("mójplik.txt", FileMode.Create);
            fs.Write(ASCIIEncoding.ASCII.GetBytes("Witaj Świecie"), 0, 11);
            fs.Close();
         }
         catch (SecurityException e)
         {
            Console.WriteLine("Wystąpił wyjątek ochrony zabezpieczeń, {0}", e.ToString());
         }
      }
   }
}
