System.Security.Permissions.FileIOPermissionAttribute Class

public sealed class FileIOPermissionAttribute : CodeAccessSecurityAttribute

Base Types

Object
  Attribute
    SecurityAttribute
      CodeAccessSecurityAttribute
        FileIOPermissionAttribute

Assembly

mscorlib

Library

BCL

Summary

Used to declaratively specify security actions to control access to files and directories.

Description

[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, System.Security.Permissions.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.

Example

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)]

Attributes

AttributeUsageAttribute(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple=true, Inherited=false)

See Also

System.Security.Permissions Namespace

Members

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


FileIOPermissionAttribute Constructor

public FileIOPermissionAttribute(SecurityAction action);

Summary

Constructs and initializes a new instance of the FileIOPermissionAttribute class with the specified SecurityAction value.

Parameters

action
A SecurityAction value.

Exceptions

Exception TypeCondition
ArgumentExceptionaction is not a valid SecurityAction value.

See Also

System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace

FileIOPermissionAttribute.CreatePermission Method

public override IPermission CreatePermission();

Summary

Returns a new System.Security.Permissions.FileIOPermission that contains the security information of the current instance.

Return Value

A new System.Security.Permissions.FileIOPermission object with the security information of the current instance.

Description

[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.

]

See Also

System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace

FileIOPermissionAttribute.All Property

public string All { set; }

Summary

Sets the name of a file or directory for which full access is secured.

Property Value

A String containing the absolute path of the file or directory for which full access is secured.

Description

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.]

See Also

System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace

FileIOPermissionAttribute.Append Property

public string Append { get; set; }

Summary

Gets or sets the name of a file or directory for which append access is secured.

Property Value

A String containing the absolute path of the file or directory for which append access is secured.

Description

[Note: This property sets append access for a single file or directory; use additional FileIOPermissionAttribute attributes to specify additional files and directories.]

See Also

System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace

FileIOPermissionAttribute.PathDiscovery Property

public string PathDiscovery { get; set; }

Summary

Gets or sets the name of a file or directory for which path discovery access is secured.

Property Value

A String containing the absolute path of the file or directory for which access to the contents of the path is secured.

Description

[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.

]

See Also

System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace

FileIOPermissionAttribute.Read Property

public string Read { get; set; }

Summary

Gets or sets the name of a file or directory for which read access is secured.

Property Value

A String containing the absolute path of the file or directory for which read access is secured.

Description

[Note: This property sets read access for a single file or directory; use additional FileIOPermissionAttribute attributes to specify additional files and directories.]

See Also

System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace

FileIOPermissionAttribute.Write Property

public string Write { get; set; }

Summary

Gets or sets the name of a file or directory for which write access is secured.

Property Value

A String containing the absolute path of the file or directory for which write access is secured.

Description

[Note: This property sets write access for a single file or directory; use additional FileIOPermissionAttribute attributes to specify additional files and directories.]

See Also

System.Security.Permissions.FileIOPermissionAttribute Class, System.Security.Permissions Namespace