public sealed class FileIOPermissionAttribute : CodeAccessSecurityAttribute
Object
Attribute
SecurityAttribute
CodeAccessSecurityAttribute
FileIOPermissionAttribute
mscorlib
BCL
Used to declaratively specify security actions to control access to files and directories.
[Note: The level of access to a file or directory is specified using the members of the current instance. For example, to specify read permissions for a file, set the System.Security.Permissions.FileIOPermissionAttribute.Read property equal to the name of the file.The security information declared by a security attribute is stored in the metadata of the attribute target, and is accessed by the system at run-time. Security attributes are used for declarative security only. For imperative security, use the corresponding permission class, FileIOPermission.
The allowable FileIOPermissionAttribute targets are determined by the SecurityAction passed to the constructor.
]
Case-sensitivity of file and directory names is platform dependent. The set of characters that are valid for use in file and directory names is determined by the current file system.
The following example shows a declarative request for full access to the specified file. The System.Security.Permissions.SecurityAction.RequestMinimum security action indicates that this is the minimum permission required for the target assembly to be able to execute.
[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, All="\\example\\sample.txt")]
The following example shows how to demand that the calling code has unrestricted access to files and directories. Demands are typically made to protect methods or classes from malicious code.
[FileIOPermissionAttribute(SecurityAction.Demand, Unrestricted=true)]
AttributeUsageAttribute(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple=true, Inherited=false)
System.Security.Permissions Namespace
FileIOPermissionAttribute Constructors
FileIOPermissionAttribute Constructor
FileIOPermissionAttribute Methods
FileIOPermissionAttribute.CreatePermission Method
FileIOPermissionAttribute Properties
FileIOPermissionAttribute.All Property
FileIOPermissionAttribute.Append Property
FileIOPermissionAttribute.PathDiscovery Property
FileIOPermissionAttribute.Read Property
FileIOPermissionAttribute.Write Property
public FileIOPermissionAttribute(SecurityAction action);
Constructs and initializes a new instance of the FileIOPermissionAttribute class with the specified SecurityAction value.
- action
- A SecurityAction value.
Exception Type Condition ArgumentException action is not a valid SecurityAction value.
System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace
public override IPermission CreatePermission();
Returns a new FileIOPermission that contains the security information of the current instance.
A new FileIOPermission object with the security information of the current instance.
[Note: Applications typically do not call this method; it is intended for use by the system.The security information declared by a security attribute is stored in the metadata of the attribute target, and is accessed by the system at run-time. The system uses the object returned by this method to convert the security information of the current instance into the form stored in metadata.
This method overrides System.Security.Permissions.SecurityAttribute.CreatePermission.
]
System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace
public string All { set; }
Sets the name of a file or directory for which full access is secured.
A String containing the absolute path of the file or directory for which full access is secured.
Exception Type Condition ArgumentException The path information specified for a set operation contains invalid characters or wild card specifiers.
This property is write-only.[Note: This property sets full access for a single file or directory; use additional FileIOPermissionAttribute attributes to specify additional files and directories.]
System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace
public string Append { get; set; }
Gets or sets the name of a file or directory for which append access is secured.
A String containing the absolute path of the file or directory for which append access is secured.
Exception Type Condition ArgumentException The path information specified for a set operation contains invalid characters or wild card specifiers.
[Note: This property sets append access for a single file or directory; use additional FileIOPermissionAttribute attributes to specify additional files and directories.]
System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace
public string PathDiscovery { get; set; }
Gets or sets the name of a file or directory for which path discovery access is secured.
A String containing the absolute path of the file or directory for which access to the contents of the path is secured.
Exception Type Condition ArgumentException The path information specified for a set operation contains invalid characters or wild card specifiers.
[Note: This property sets path discovery access for a single file or directory; use additional FileIOPermissionAttribute attributes to specify additional files and directories.Path discovery controls access to the information in the path itself. This protects sensitive information in the path, such as user names, as well as information about the directory structure revealed in the path. This value does not secure access to files or folders represented by the path.
]
System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace
public string Read { get; set; }
Gets or sets the name of a file or directory for which read access is secured.
A String containing the absolute path of the file or directory for which read access is secured.
Exception Type Condition ArgumentException The path information specified for a set operation contains invalid characters or wild card specifiers.
[Note: This property sets read access for a single file or directory; use additional FileIOPermissionAttribute attributes to specify additional files and directories.]
System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace
public string Write { get; set; }
Gets or sets the name of a file or directory for which write access is secured.
A String containing the absolute path of the file or directory for which write access is secured.
Exception Type Condition ArgumentException The path information specified for a set operation contains invalid characters or wild card specifiers.
[Note: This property sets write access for a single file or directory; use additional FileIOPermissionAttribute attributes to specify additional files and directories.]
System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace