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.

參數指定所path指定之檔案或目錄的存取控制清單 (ACL) 是否可以變更、查看或無法存取。 controlThe 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.

參數指定所path指定之檔案或目錄的存取控制清單 (ACL) 是否可以變更、查看或無法存取。 controlThe 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.

適用於