Permission sets : File Permission « File Directory Stream « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Security;
using System.Security.AccessControl;
using System.Security.Policy;
using System.Security.Permissions;
using System.Security.Principal;
using System.Text;

public class MainClass
{
    public static void Main()
    {
        NamedPermissionSet ps = new NamedPermissionSet("SamplePermissionSet", PermissionState.None);
        ps.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, @"C:\test\"));
        ps.AddPermission(new ReflectionPermission(PermissionState.Unrestricted));
        ps.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));

        Console.WriteLine(ps.ToXml().ToString());
    }
}












15.12.File Permission
15.12.1.Requesting minimum permissions
15.12.2.Requesting optional permissions
15.12.3.Requesting a permission set
15.12.4.Refusing permissions
15.12.5.Demanding permissions
15.12.6.Permission sets
15.12.7.Declarative Permission demo