// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Security; using System.Security.Permissions; namespace E { public class Program { public static void TestIO() { try { File.Create(@"C:\z.z").Close(); Console.WriteLine("IO OK"); } catch(SecurityException) { Console.WriteLine("IO not OK"); } } public static void TestRevert() { try { CodeAccessPermission.RevertDeny(); Console.WriteLine("Revert OK"); } catch(ExecutionEngineException) { Console.WriteLine("Revert not OK"); } } public static void Main(string[] args) { TestIO(); CodeAccessPermission ioperm = new FileIOPermission(PermissionState.Unrestricted); ioperm.Deny(); TestIO(); TestRevert(); CodeAccessPermission.RevertDeny(); TestIO(); } } }