public sealed class FileIOPermission : CodeAccessPermission
Object
CodeAccessPermission
FileIOPermissionThis type implements IPermission.
mscorlib
BCL
Secures access to files and directories.
FileIOPermission objects describe protected operations on files and directories. Files and directories are specified using absolute paths. Case-sensitivity of files and directories is platform and file system dependent.[Note: This permission distinguishes between the following types of file I/O access provided by FileIOPermissionAccess:
These access levels are independent, meaning that rights to one do not imply rights to another. For example,
Read
: Read access to the contents of the file or access to information about the file, such as its length or last modification time.Write
: Write access to the contents of the file or access to change information about the file, such as its name. Also allows for deletion and overwriting.Append
: Ability to write to the end of a file only.PathDiscovery
: Ability to obtain path information about a file.NoAccess
: No access to the file or directory.AllAccess
: Full access to the file or directory.Write
permission does not imply permission toRead
orAppend
. FileIOPermissionAccess values can be combined using a bitwise OR operator.For information on security considerations when accessing files, see FileStream .
]
The XML encoding of a
FileIOPermission
instance is defined below in EBNF format. The following conventions are used:
The following meta-language symbols are used:
- All non-literals in the grammar below are shown in normal type.
- All literals are in bold font.
BuildVersion refers to the build version of the shipping CLI. This is specified as a dotted build number such as '2412.0' .
- '*' represents a meta-language symbol suffixing an expression that can appear zero or more times.
- '?' represents a meta-language symbol suffixing an expression that can appear zero or one time.
- '+' represents a meta-language symbol suffixing an expression that can appear one or more times.
- '(',')' is used to group literals, non-literals or a mixture of literals and non-literals.
- '|' denotes an exclusive disjunction between two expressions.
- '::= ' denotes a production rule where a left hand non-literal is replaced by a right hand expression containing literals, non-literals or both.
ECMAPubKeyToken ::=
b77a5c561934e089
FileName refers to the full path and file name of a file, or to a path name, such as "
C:\Temp\test.exe
" or "C:\
".The XML encoding of a
FileIOPermission
instance is as follows:FileIOPermissionXML ::=
<IPermission
class="
System.Security.Permissions.FileIOPermission,
mscorlib,
Version=1.0.
BuildVersion,
Culture=neutral,
PublicKeyToken=
ECMAPubKeyToken"
version="1"
(
Unrestricted="true"
)
|
(
(
Read="
FileName (;
FileName )*"
) ?
(
Write="
FileName (;
FileName )*"
) ?
(
Append="
FileName (;
FileName )*"
) ?
(
PathDiscovery="
FileName (;
FileName )*"
) ?
)
/>
System.Security.Permissions Namespace
FileIOPermission Constructors
FileIOPermission(System.Security.Permissions.PermissionState) Constructor
FileIOPermission(System.Security.Permissions.FileIOPermissionAccess, System.String) Constructor
FileIOPermission Methods
FileIOPermission.Copy Method
FileIOPermission.FromXml Method
FileIOPermission.Intersect Method
FileIOPermission.IsSubsetOf Method
FileIOPermission.ToXml Method
FileIOPermission.Union Method
public FileIOPermission(PermissionState state);
Constructs and initializes a new instance of the FileIOPermission class with the specified PermissionState value.
- state
- A PermissionState value.
Exception Type Condition ArgumentException state is not a valid PermissionState value.
[Note: This constructor creates either fully restricted (System.Security.Permissions.PermissionState.None) or System.Security.Permissions.PermissionState.Unrestricted access to files and directories.]
System.Security.Permissions.FileIOPermission Class, System.Security.Permissions Namespace
public FileIOPermission(FileIOPermissionAccess access, string path);
Constructs and initializes a new instance of the FileIOPermission class with the specified access to the specified file or directory.
- access
- One or more values defined in FileIOPermissionAccess. Specify multiple values using the bitwise OR operator.
- path
- The absolute path of the file or directory.
Exception Type Condition ArgumentException access specifies values not defined in FileIOPermissionAccess. path contains one or more characters that are invalid for use in files or directory names.
path did not specify the absolute path to the file or directory.
The set of characters that are invalid for use in file or directory names is platform specific.
System.Security.Permissions.FileIOPermission Class, System.Security.Permissions Namespace
public override IPermission Copy();
Returns a new FileIOPermission object containing the same values as the current instance.
A new FileIOPermission containing the same values as the current instance.
[Note: The object returned by this method represents the same level of access to files and directories as the current instance.This method overrides System.Security.CodeAccessPermission.Copy and is implemented to support the IPermission interface.
]
System.Security.Permissions.FileIOPermission Class, System.Security.Permissions Namespace
public override void FromXml(SecurityElement esd);
Reconstructs the state of a FileIOPermission object using the specified XML encoding.
- esd
- A SecurityElement instance containing the XML encoding to use to reconstruct the state of a FileIOPermission object.
Exception Type Condition ArgumentNullException esd is null
.ArgumentException esd does not contain the encoding for a FileIOPermission instance. The version number of esd is not valid.
The state of the current instance is changed to the state encoded in esd.[Note: For the XML encoding for this class, see the FileIOPermission class page.
This method overrides System.Security.CodeAccessPermission.FromXml(System.Security.SecurityElement).
]
System.Security.Permissions.FileIOPermission Class, System.Security.Permissions Namespace
public override IPermission Intersect(IPermission target);
Returns a new FileIOPermission object that is the intersection of the current instance and the specified object.
- target
- A FileIOPermission instance to intersect with the current instance.
A new FileIOPermission instance that represents the intersection of the current instance and target. If the intersection is empty or target isnull
, returnsnull
. If the current instance is unrestricted, returns a copy of target. If target is unrestricted, returns a copy of the current instance.
Exception Type Condition ArgumentException target is not null
and is not of type FileIOPermission .
[Note: The intersection of two permissions is a permission that secures the resources and operations secured by both permissions. Specifically, it represents the minimum permission such that any demand that passes both permissions will also pass their intersection.This method overrides System.Security.CodeAccessPermission.Intersect(System.Security.IPermission) and is implemented to support the IPermission interface.
]
System.Security.Permissions.FileIOPermission Class, System.Security.Permissions Namespace
public override bool IsSubsetOf(IPermission target);
Determines whether the current instance is a subset of the specified object.
- target
- A FileIOPermission instance that is to be tested for the subset relationship.
true
if the current instance is a subset of target ; otherwise,false
. If the current instance is unrestricted, and target is not, returnsfalse
. If target is unrestricted, returnstrue
. If target isnull
and no files or directories are secured by the current instance, returnstrue
. If target isnull
, and the current instance secures one or more files or directories, returnsfalse
.
Exception Type Condition ArgumentException target is not null
and is not of type FileIOPermission .
[Note: The current instance is a subset of target if the current instance specifies a set of accesses to resources that is wholly contained by target. For example, a permission that represents read access to a file is a subset of a permission that represents read and write access to the file.If this method returns
true
, the current instance describes a level of access to files and directories that is also described by target.This method overrides System.Security.CodeAccessPermission.IsSubsetOf(System.Security.IPermission) and is implemented to support the IPermission interface.
]
System.Security.Permissions.FileIOPermission Class, System.Security.Permissions Namespace
public override SecurityElement ToXml();
Returns the XML encoding of the current instance.
A SecurityElement containing the XML encoding of the state of the current instance.
[Note: For the XML encoding for this class, see the FileIOPermission class page.This method overrides System.Security.CodeAccessPermission.ToXml .
]
System.Security.Permissions.FileIOPermission Class, System.Security.Permissions Namespace
public override IPermission Union(IPermission other);
Returns a new FileIOPermission that is the union of the current instance and the specified object.
- other
- A FileIOPermission instance to combine with the current instance.
A new FileIOPermission instance that represents the union of the current instance and other . If the current instance or other is unrestricted, returns a FileIOPermission instance that is unrestricted. If other isnull
, returns a copy of the current instance via the System.Security.IPermission.Copy method. If the current instance and other do not specify any file or directory names, returnsnull
.
Exception Type Condition ArgumentException other is not null
and is not of type FileIOPermission .
[Note: The result of a call to System.Security.Permissions.FileIOPermission.Union(System.Security.IPermission) is a permission that represents all of the access to files and directories represented by the current instance as well as the access to files and directories represented by other. Any demand that passes either the current instance or other passes their union.This method overrides System.Security.CodeAccessPermission.Union(System.Security.IPermission) and is implemented to support the IPermission interface.
]
System.Security.Permissions.FileIOPermission Class, System.Security.Permissions Namespace