// Create a permission to read input.txt

FileIOPermission fp = new FileIOPermission(FileIOPermissionAccess.Read, "input.txt");

// Add a permission to read and write output.txt

fp.AddPathList(FileIOPermissionAccess.Read.Write | FileIOPermissionAccess.Read.Read, "output.txt");

try

{

// Verify that those permissions are available.

// Demand throws an exception if they are not.

fp.Demand();

}

catch (SecurityException s)

{

// TODO: Handle the missing file access permissions.

}