FileIOPermission.AddPathList Method

Definition

Adds access for the specified files and directories to the existing state of the permission.

Overloads

AddPathList(FileIOPermissionAccess, String)

Adds access for the specified file or directory to the existing state of the permission.

AddPathList(FileIOPermissionAccess, String[])

Adds access for the specified files and directories to the existing state of the permission.

AddPathList(FileIOPermissionAccess, String)

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

Adds access for the specified file or directory to the existing state of the permission.

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

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess values.

path
String

The absolute path of a 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 did not specify the absolute path to the file or directory.

The path parameter is null.

The path parameter has an invalid format.

Examples

The following code example shows the use of the FileIOPermission.AddPathList(FileIOPermissionAccess, String) method.

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

Use this method to modify file and directory access by adding to the state of the current permission.

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

AddPathList(FileIOPermissionAccess, String[])

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

Adds access for the specified files and directories to the existing state of the permission.

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

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess 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 valid.

An entry in the pathList array has an invalid format.

The pathList parameter is null.

Remarks

Use this method to modify file and directory access by adding to the state of the current permission.

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