The calling code can access the resource identified by the current permission object, even if callers higher in the stack have not been granted permission to access the resource (see Using the Assert Method).

Demand

All callers higher in the call stack are required to have been granted the permission specified by the current permission object (see Security Demands).

Deny

The ability to access the resource specified by the current permission object is denied to callers, even if they have been granted permission to access it (see Using the Deny Method).

InheritanceDemand

The derived class inheriting the class or overriding a method is required to have been granted the specified permission.

LinkDemand

The immediate caller is required to have been granted the specified permission.

Only the resources specified by this permission object can be accessed, even if the code has been granted permission to access other resources (see Using the PermitOnly Method).

RequestMinimum

The request for the minimum permissions required for code to run. This action can only be used within the scope of the assembly.

RequestOptional

The request for additional permissions that are optional (not required to run). This request implicitly refuses all other permissions not specifically requested. This action can only be used within the scope of the assembly.

RequestRefuse

The request that permissions that might be misused will not be granted to the calling code. This action can only be used within the scope of the assembly.

using System;
using System.Security.Permissions;
using System.IO.IsolatedStorage;
using System.IO;
// Notify the CLR to grant this assembly the IsolatedStorageFilePermission. // This allows the assembly to work with storage files that are isolated // by user and assembly.
[assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByUser)]
publicsealedclass App
{
staticvoid Main()
{
// Attempt to create a storage file that is isolated by user and assembly.// IsolatedStorageFilePermission granted to the attribute at the top of this file // allows CLR to load this assembly and execution of this statement.using (Stream s = new IsolatedStorageFileStream("AssemblyData", FileMode.Create, IsolatedStorageFile.GetUserStoreForAssembly()))
{
// Write some data out to the isolated file.using (StreamWriter sw = new StreamWriter(s))
{
sw.Write("This is some test data.");
}
}
// Attempt to open the file that was previously created.using (Stream s = new IsolatedStorageFileStream("AssemblyData", FileMode.Open, IsolatedStorageFile.GetUserStoreForAssembly()))
{
// Read the data from the file and display it.using (StreamReader sr = new StreamReader(s))
{
Console.WriteLine(sr.ReadLine());
}
}
}
}
// This code produces the following output.//// Some test data.