FileIOPermission FileIOPermission FileIOPermission FileIOPermission Constructors

定義

多載

FileIOPermission(PermissionState) FileIOPermission(PermissionState) FileIOPermission(PermissionState) FileIOPermission(PermissionState)

依照指定使用完全限制或無限制的權限,初始化 FileIOPermission 類別的新執行個體。Initializes a new instance of the FileIOPermission class with fully restricted or unrestricted permission as specified.

FileIOPermission(FileIOPermissionAccess, String) FileIOPermission(FileIOPermissionAccess, String) FileIOPermission(FileIOPermissionAccess, String) FileIOPermission(FileIOPermissionAccess, String)

初始化具有指定檔案或目錄之指定存取權的 FileIOPermission 類別的新執行個體。Initializes a new instance of the FileIOPermission class with the specified access to the designated file or directory.

FileIOPermission(FileIOPermissionAccess, String[]) FileIOPermission(FileIOPermissionAccess, String[]) FileIOPermission(FileIOPermissionAccess, String[]) FileIOPermission(FileIOPermissionAccess, String[])

初始化具有指定檔案及目錄之指定存取權的 FileIOPermission 類別的新執行個體。Initializes a new instance of the FileIOPermission class with the specified access to the designated files and directories.

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String)

以針對指定檔案或目錄的指定存取權限和檔案控制資訊的指定存取權限,初始化 FileIOPermission 類別的新執行個體。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[]) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[]) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[]) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[])

以針對指定檔案和目錄的指定存取權限和檔案控制資訊的指定存取權限,初始化 FileIOPermission 類別的新執行個體。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) FileIOPermission(PermissionState) FileIOPermission(PermissionState) FileIOPermission(PermissionState)

依照指定使用完全限制或無限制的權限,初始化 FileIOPermission 類別的新執行個體。Initializes a new instance of the FileIOPermission class with fully restricted or unrestricted permission as specified.

public:
 FileIOPermission(System::Security::Permissions::PermissionState state);
public FileIOPermission (System.Security.Permissions.PermissionState state);
new System.Security.Permissions.FileIOPermission : System.Security.Permissions.PermissionState -> System.Security.Permissions.FileIOPermission
Public Sub New (state As PermissionState)

參數

state
PermissionState PermissionState PermissionState PermissionState

其中一個 PermissionState 列舉值。One of the PermissionState enumeration values.

例外狀況

state 參數不是有效的 PermissionState 值。The state parameter is not a valid value of PermissionState.

範例

下列程式碼範例會建立的新執行個體FileIOPermission類別完全受限制的讀取權限。The following code example creates a new instance of the FileIOPermission class with fully restricted read access.

FileIOPermission^ f = gcnew FileIOPermission( PermissionState::None );
f->AllLocalFiles = FileIOPermissionAccess::Read;
try
{
 f->Demand();
}
catch (SecurityException^ s)
{
 Console::WriteLine(s->Message);
}
FileIOPermission f = new FileIOPermission(PermissionState.None);
f.AllLocalFiles = FileIOPermissionAccess.Read;
try
{
    f.Demand();
}
catch (SecurityException s)
{
    Console.WriteLine(s.Message);
}

Dim f As New FileIOPermission(PermissionState.None)
f.AllLocalFiles = FileIOPermissionAccess.Read
Try
    f.Demand()
Catch s As SecurityException
    Console.WriteLine(s.Message)
End Try

備註

會建立完全受限制 (None) 或Unrestricted檔案和目錄的存取。Creates either fully restricted (None) or Unrestricted access to files and directories.

FileIOPermission(FileIOPermissionAccess, String) FileIOPermission(FileIOPermissionAccess, String) FileIOPermission(FileIOPermissionAccess, String) FileIOPermission(FileIOPermissionAccess, String)

初始化具有指定檔案或目錄之指定存取權的 FileIOPermission 類別的新執行個體。Initializes a new instance of the FileIOPermission class with the specified access to the designated file or directory.

public:
 FileIOPermission(System::Security::Permissions::FileIOPermissionAccess access, System::String ^ path);
public FileIOPermission (System.Security.Permissions.FileIOPermissionAccess access, string path);
new System.Security.Permissions.FileIOPermission : System.Security.Permissions.FileIOPermissionAccess * string -> System.Security.Permissions.FileIOPermission
Public Sub New (access As FileIOPermissionAccess, path As String)

參數

access
FileIOPermissionAccess FileIOPermissionAccess FileIOPermissionAccess FileIOPermissionAccess

FileIOPermissionAccess 列舉值的位元組合。A bitwise combination of the FileIOPermissionAccess enumeration values.

path
String String String String

檔案或目錄的絕對路徑。The absolute path of the 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 does not specify the absolute path to the file or directory.

範例

下列程式碼範例示範使用FileIOPermission.FileIOPermission(FileIOPermissionAccess, String)建構函式建立的新執行個體FileIOPermission類別,可提供 C:\test_r 檔案的完整權限。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.

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

備註

這個建構函式只允許其中FileIOPermissionAccess值指定為指定的檔案或目錄。This constructor allows only one of the FileIOPermissionAccess values to be specified for the specified file or directory. 使用AddPathList方法來定義複雜的權限。Use the AddPathList method to define complex permissions.

FileIOPermission(FileIOPermissionAccess, String[]) FileIOPermission(FileIOPermissionAccess, String[]) FileIOPermission(FileIOPermissionAccess, String[]) FileIOPermission(FileIOPermissionAccess, String[])

初始化具有指定檔案及目錄之指定存取權的 FileIOPermission 類別的新執行個體。Initializes a new instance of the FileIOPermission class with the specified access to the designated files and directories.

public:
 FileIOPermission(System::Security::Permissions::FileIOPermissionAccess access, cli::array <System::String ^> ^ pathList);
public FileIOPermission (System.Security.Permissions.FileIOPermissionAccess access, string[] pathList);
new System.Security.Permissions.FileIOPermission : System.Security.Permissions.FileIOPermissionAccess * string[] -> System.Security.Permissions.FileIOPermission
Public Sub New (access As FileIOPermissionAccess, pathList As String())

參數

access
FileIOPermissionAccess FileIOPermissionAccess FileIOPermissionAccess FileIOPermissionAccess

FileIOPermissionAccess 列舉值的位元組合。A bitwise combination of the FileIOPermissionAccess enumeration values.

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 a valid string.

備註

這個建構函式只允許一個FileIOPermissionAccess為指定的檔案和目錄指定的值。This constructor allows only one FileIOPermissionAccess value to be specified for the specified files and directories. 使用AddPathList方法來定義複雜的權限。Use the AddPathList method to define complex permissions.

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String)

以針對指定檔案或目錄的指定存取權限和檔案控制資訊的指定存取權限,初始化 FileIOPermission 類別的新執行個體。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.

public:
 FileIOPermission(System::Security::Permissions::FileIOPermissionAccess access, System::Security::AccessControl::AccessControlActions control, System::String ^ path);
public FileIOPermission (System.Security.Permissions.FileIOPermissionAccess access, System.Security.AccessControl.AccessControlActions control, string path);
new System.Security.Permissions.FileIOPermission : System.Security.Permissions.FileIOPermissionAccess * System.Security.AccessControl.AccessControlActions * string -> System.Security.Permissions.FileIOPermission
Public Sub New (access As FileIOPermissionAccess, control As AccessControlActions, path As String)

參數

access
FileIOPermissionAccess FileIOPermissionAccess FileIOPermissionAccess FileIOPermissionAccess

FileIOPermissionAccess 列舉值的位元組合。A bitwise combination of the FileIOPermissionAccess enumeration values.

actions
AccessControlActions AccessControlActions AccessControlActions AccessControlActions

AccessControlActions 列舉值的位元組合。A bitwise combination of the AccessControlActions enumeration values.

path
String String String String

檔案或目錄的絕對路徑。The absolute path of the 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 does not specify the absolute path to the file or directory.

備註

這個建構函式只允許一個FileIOPermissionAccess為指定的檔案或目錄指定的值。This constructor allows only one FileIOPermissionAccess value to be specified for the specified file or directories. 使用AddPathList方法來定義複雜的權限。Use the AddPathList method to define complex permissions.

control參數會指定是否的存取控制清單 (ACL) 的檔案或目錄所指定path可以變更,檢視,或無法存取。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.

重要

存取控制清單 (ACL) 會描述個人或群組,或沒有,在指定的檔案和其屬性的特定動作的權限。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. 變更或檢視 ACL 的能力是很重要的權限,並應謹慎使用授與。The ability to change or view an ACL is an important permission and should be granted with caution.

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[]) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[]) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[]) FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[])

以針對指定檔案和目錄的指定存取權限和檔案控制資訊的指定存取權限,初始化 FileIOPermission 類別的新執行個體。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.

public:
 FileIOPermission(System::Security::Permissions::FileIOPermissionAccess access, System::Security::AccessControl::AccessControlActions control, cli::array <System::String ^> ^ pathList);
public FileIOPermission (System.Security.Permissions.FileIOPermissionAccess access, System.Security.AccessControl.AccessControlActions control, string[] pathList);
new System.Security.Permissions.FileIOPermission : System.Security.Permissions.FileIOPermissionAccess * System.Security.AccessControl.AccessControlActions * string[] -> System.Security.Permissions.FileIOPermission
Public Sub New (access As FileIOPermissionAccess, control As AccessControlActions, pathList As String())

參數

access
FileIOPermissionAccess FileIOPermissionAccess FileIOPermissionAccess FileIOPermissionAccess

FileIOPermissionAccess 列舉值的位元組合。A bitwise combination of the FileIOPermissionAccess enumeration values.

actions
AccessControlActions AccessControlActions AccessControlActions AccessControlActions

AccessControlActions 列舉值的位元組合。A bitwise combination of the AccessControlActions enumeration values.

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 a valid string.

備註

這個建構函式只允許一個FileIOPermissionAccess為指定的檔案和目錄指定的值。This constructor allows only one FileIOPermissionAccess value to be specified for the specified files and directories. 使用AddPathList方法來定義複雜的權限。Use the AddPathList method to define complex permissions.

control參數會指定是否的存取控制清單 (ACL) 的檔案或目錄所指定path可以變更,檢視,或無法存取。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.

重要

存取控制清單 (ACL) 會描述個人或群組,或沒有,在指定的檔案和其屬性的特定動作的權限。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. 變更或檢視 ACL 的能力是很重要的權限,並應謹慎使用授與。The ability to change or view an ACL is an important permission and should be granted with caution.

適用於