Test if the current assembly has the specified permission : Permissions « Security « C# / CSharp Tutorial






using System;
using System.Security;
using System.Security.Permissions;

class MainClass
{
    public static void Main()
    {
        FileIOPermission fileIOPerm = new FileIOPermission(FileIOPermissionAccess.Write, @"C:\Data");
        Console.WriteLine(SecurityManager.IsGranted(fileIOPerm));
    }
}
True








35.4.Permissions
35.4.1.UnmanagedCode element of SecurityPermission( controls the code’s ability to execute unmanaged code)
35.4.2.File IO Permission: SecurityAction.RequestRefuse, Write
35.4.3.Internet SecurityAction
35.4.4.Optional permission request for IsolatedStorageFilePermission
35.4.5.Refuse request for ReflectionPermission
35.4.6.Test if the current assembly has the specified permission
35.4.7.Specify the certification file
35.4.8.A declarative role-based security demand for the current principal
35.4.9.A declarative role-based security demand for the current principal to be a member of the roles Managers OR Developers
35.4.10.An imperative role-based security demand for the current principal to represent an identity with the name Anya AND be a member of the Managers role
35.4.11.An imperative role-based security demand for the current principal to represent an identity with the name Anya, the roles of the principal are irrelevant
35.4.12.PrincipalPolicy.Intersect/Union
35.4.13.Create PrincipalPermission for Administrators