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.

适用于