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)

将指定文件或目录的访问权限添加到现有的权限状态。Adds access for the specified file or directory to the existing state of the permission.

public:
 void AddPathList(System::Security::Permissions::FileIOPermissionAccess access, System::String ^ path);
public void AddPathList (System.Security.Permissions.FileIOPermissionAccess access, string path);
member this.AddPathList : System.Security.Permissions.FileIOPermissionAccess * string -> unit
Public Sub AddPathList (access As FileIOPermissionAccess, path As String)

Parameters

access
FileIOPermissionAccess

FileIOPermissionAccess 值的按位组合。A bitwise combination of the FileIOPermissionAccess values.

path
String

文件或目录的绝对路径。The absolute path of a file or directory.

Exceptions

access 参数不是 FileIOPermissionAccess 的有效值。The access parameter is not a valid value of FileIOPermissionAccess.

- 或 --or- path 参数不是有效的字符串。The path parameter is not a valid string.

- 或 --or- path 参数未指定文件或目录的绝对路径。The path parameter did not specify the absolute path to the file or directory.

path 参数为 nullThe path parameter is null.

path 参数的格式无效。The path parameter has an invalid format.

Examples

下面的代码示例演示如何使用 FileIOPermission.AddPathList(FileIOPermissionAccess, String) 方法。The following code example shows the use of the FileIOPermission.AddPathList(FileIOPermissionAccess, String) method.

FileIOPermission^ f2 = gcnew FileIOPermission( FileIOPermissionAccess::Read,"C:\\test_r" );
f2->AddPathList( (FileIOPermissionAccess) (FileIOPermissionAccess::Write | FileIOPermissionAccess::Read), "C:\\example\\out.txt" );
try
{
    f2->Demand();
}
catch (SecurityException^ s)
{
    Console::WriteLine(s->Message);
}
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);
}
Dim f2 As New FileIOPermission(FileIOPermissionAccess.Read, "C:\test_r")
f2.AddPathList(FileIOPermissionAccess.Write Or FileIOPermissionAccess.Read, "C:\example\out.txt")
Try
    f2.Demand()
Catch s As SecurityException
    Console.WriteLine(s.Message)
End Try

Remarks

通过将添加到当前权限的状态,使用此方法修改文件和目录访问。Use this method to modify file and directory access by adding to the state of the current permission.

AddPathList(FileIOPermissionAccess, String[])

将指定文件和目录的访问权限添加到现有的权限状态中。Adds access for the specified files and directories to the existing state of the permission.

public:
 void AddPathList(System::Security::Permissions::FileIOPermissionAccess access, cli::array <System::String ^> ^ pathList);
public void AddPathList (System.Security.Permissions.FileIOPermissionAccess access, string[] pathList);
member this.AddPathList : System.Security.Permissions.FileIOPermissionAccess * string[] -> unit
Public Sub AddPathList (access As FileIOPermissionAccess, pathList As String())

Parameters

access
FileIOPermissionAccess

FileIOPermissionAccess 值的按位组合。A bitwise combination of the FileIOPermissionAccess values.

pathList
String[]

包含文件和目录的绝对路径的数组。An array containing the absolute paths of the files and directories.

Exceptions

access 参数不是 FileIOPermissionAccess 的有效值。The access parameter is not a valid value of FileIOPermissionAccess.

- 或 --or- pathList 数组中的条目无效。An entry in the pathList array is not valid.

pathList 数组中的条目具有无效的格式。An entry in the pathList array has an invalid format.

pathList 参数为 nullThe 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