FileIOPermission.AddPathList FileIOPermission.AddPathList FileIOPermission.AddPathList FileIOPermission.AddPathList Method

定义

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

重载

AddPathList(FileIOPermissionAccess, String) AddPathList(FileIOPermissionAccess, String) AddPathList(FileIOPermissionAccess, String) AddPathList(FileIOPermissionAccess, String)

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

AddPathList(FileIOPermissionAccess, String[]) AddPathList(FileIOPermissionAccess, String[]) AddPathList(FileIOPermissionAccess, String[]) AddPathList(FileIOPermissionAccess, String[])

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

AddPathList(FileIOPermissionAccess, String) AddPathList(FileIOPermissionAccess, String) AddPathList(FileIOPermissionAccess, String) 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)

参数

path
String String String String

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

异常

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 参数的格式无效。The path parameter has an invalid format.

示例

下面的代码示例演示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

注解

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

AddPathList(FileIOPermissionAccess, String[]) AddPathList(FileIOPermissionAccess, String[]) AddPathList(FileIOPermissionAccess, String[]) 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())

参数

pathList
String[]

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

异常

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.

注解

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

适用于