FileIOPermission Constructors

Definition

Initializes a new instance of the FileIOPermission class.

Overloads

FileIOPermission(PermissionState)

Initializes a new instance of the FileIOPermission class with fully restricted or unrestricted permission as specified.

FileIOPermission(FileIOPermissionAccess, String)

Initializes a new instance of the FileIOPermission class with the specified access to the designated file or directory.

FileIOPermission(FileIOPermissionAccess, String[])

Initializes a new instance of the FileIOPermission class with the specified access to the designated files and directories.

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String)

Initializes a new instance of the FileIOPermission class with the specified access to the designated file or directory and the specified access rights to file control information.

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[])

Initializes a new instance of the FileIOPermission class with the specified access to the designated files and directories and the specified access rights to file control information.

FileIOPermission(PermissionState)

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

Initializes a new instance of the FileIOPermission class with fully restricted or unrestricted permission as specified.

C#
public FileIOPermission(System.Security.Permissions.PermissionState state);

Parameters

state
PermissionState

One of the PermissionState enumeration values.

Exceptions

The state parameter is not a valid value of PermissionState.

Examples

The following code example creates a new instance of the FileIOPermission class with fully restricted read access.

C#
FileIOPermission f = new FileIOPermission(PermissionState.None);
f.AllLocalFiles = FileIOPermissionAccess.Read;
try
{
    f.Demand();
}
catch (SecurityException s)
{
    Console.WriteLine(s.Message);
}

Remarks

Creates either fully restricted (None) or Unrestricted access to files and directories.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

FileIOPermission(FileIOPermissionAccess, String)

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

Initializes a new instance of the FileIOPermission class with the specified access to the designated file or directory.

C#
public FileIOPermission(System.Security.Permissions.FileIOPermissionAccess access, string path);

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess enumeration values.

path
String

The absolute path of the file or directory.

Exceptions

The access parameter is not a valid value of FileIOPermissionAccess.

-or-

The path parameter is not a valid string.

-or-

The path parameter does not specify the absolute path to the file or directory.

Examples

The following code example shows the use of the FileIOPermission.FileIOPermission(FileIOPermissionAccess, String) constructor to create a new instance of the FileIOPermission class, which provides complete access to the C:\test_r file.

C#
FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Read, "C:\\test_r");
f2.AddPathList(FileIOPermissionAccess.Write | FileIOPermissionAccess.Read, "C:\\example\\out.txt");
try
{
    f2.Demand();
}
catch (SecurityException s)
{
    Console.WriteLine(s.Message);
}

Remarks

This constructor allows only one of the FileIOPermissionAccess values to be specified for the specified file or directory. Use the AddPathList method to define complex permissions.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

FileIOPermission(FileIOPermissionAccess, String[])

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

Initializes a new instance of the FileIOPermission class with the specified access to the designated files and directories.

C#
public FileIOPermission(System.Security.Permissions.FileIOPermissionAccess access, string[] pathList);

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess enumeration values.

pathList
String[]

An array containing the absolute paths of the files and directories.

Exceptions

The access parameter is not a valid value of FileIOPermissionAccess.

-or-

An entry in the pathList array is not a valid string.

Remarks

This constructor allows only one FileIOPermissionAccess value to be specified for the specified files and directories. Use the AddPathList method to define complex permissions.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String)

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

Initializes a new instance of the FileIOPermission class with the specified access to the designated file or directory and the specified access rights to file control information.

C#
public FileIOPermission(System.Security.Permissions.FileIOPermissionAccess access, System.Security.AccessControl.AccessControlActions actions, string path);
C#
public FileIOPermission(System.Security.Permissions.FileIOPermissionAccess access, System.Security.AccessControl.AccessControlActions control, string path);

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess enumeration values.

actionscontrol
AccessControlActions

A bitwise combination of the AccessControlActions enumeration values.

path
String

The absolute path of the file or directory.

Exceptions

The access parameter is not a valid value of FileIOPermissionAccess.

-or-

The path parameter is not a valid string.

-or-

The path parameter does not specify the absolute path to the file or directory.

Remarks

This constructor allows only one FileIOPermissionAccess value to be specified for the specified file or directories. Use the AddPathList method to define complex permissions.

The control parameter specifies whether the access control list (ACL) for the file or directory specified by path can be changed, viewed, or cannot be accessed.

Important

An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to change or view an ACL is an important permission and should be granted with caution.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[])

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

Initializes a new instance of the FileIOPermission class with the specified access to the designated files and directories and the specified access rights to file control information.

C#
public FileIOPermission(System.Security.Permissions.FileIOPermissionAccess access, System.Security.AccessControl.AccessControlActions actions, string[] pathList);
C#
public FileIOPermission(System.Security.Permissions.FileIOPermissionAccess access, System.Security.AccessControl.AccessControlActions control, string[] pathList);

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess enumeration values.

actionscontrol
AccessControlActions

A bitwise combination of the AccessControlActions enumeration values.

pathList
String[]

An array containing the absolute paths of the files and directories.

Exceptions

The access parameter is not a valid value of FileIOPermissionAccess.

-or-

An entry in the pathList array is not a valid string.

Remarks

This constructor allows only one FileIOPermissionAccess value to be specified for the specified files and directories. Use the AddPathList method to define complex permissions.

The control parameter specifies whether the access control list (ACL) for the file or directory specified by path can be changed, viewed, or cannot be accessed.

Important

An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to change or view an ACL is an important permission and should be granted with caution.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10