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.

適用於