FileIOPermission 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 FileIOPermission 类的新实例。
重载
FileIOPermission(PermissionState) |
根据指定,使用完全受限制或不受限制的权限初始化 FileIOPermission 类的新实例。 |
FileIOPermission(FileIOPermissionAccess, String) |
初始化对指定文件或目录具有指定访问权限的 FileIOPermission 类的新实例。 |
FileIOPermission(FileIOPermissionAccess, String[]) |
初始化对指定文件和目录具有指定访问权限的 FileIOPermission 类的新实例。 |
FileIOPermission(FileIOPermissionAccess, AccessControlActions, String) |
使用对指定文件或目录的指定访问权限和对文件控制信息的指定访问权限初始化 FileIOPermission 类的新实例。 |
FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[]) |
使用对指定文件和目录的指定访问权限和对文件控制信息的指定访问权限初始化 FileIOPermission 类的新实例。 |
FileIOPermission(PermissionState)
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
根据指定,使用完全受限制或不受限制的权限初始化 FileIOPermission 类的新实例。
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 枚举值之一。
例外
state
参数不是 PermissionState 的有效值。
示例
下面的代码示例创建具有完全受限读取访问权限的 FileIOPermission 类的新实例。
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
对文件和目录的访问权限。
适用于
FileIOPermission(FileIOPermissionAccess, String)
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
初始化对指定文件或目录具有指定访问权限的 FileIOPermission 类的新实例。
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 枚举值的按位组合。
- path
- String
文件或目录的绝对路径。
例外
示例
下面的代码示例演示如何使用 FileIOPermission.FileIOPermission(FileIOPermissionAccess, String) 构造函数创建 类的新实例 FileIOPermission ,从而提供对 C:\test_r 文件的完整访问。
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 值。 AddPathList使用 方法定义复杂权限。
适用于
FileIOPermission(FileIOPermissionAccess, String[])
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
初始化对指定文件和目录具有指定访问权限的 FileIOPermission 类的新实例。
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 枚举值的按位组合。
- pathList
- String[]
包含文件和目录的绝对路径的数组。
例外
注解
此构造函数只允许为指定的文件和目录指定一个 FileIOPermissionAccess 值。 AddPathList使用 方法定义复杂权限。
适用于
FileIOPermission(FileIOPermissionAccess, AccessControlActions, String)
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
使用对指定文件或目录的指定访问权限和对文件控制信息的指定访问权限初始化 FileIOPermission 类的新实例。
public:
FileIOPermission(System::Security::Permissions::FileIOPermissionAccess access, System::Security::AccessControl::AccessControlActions actions, System::String ^ path);
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 actions, 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
new System.Security.Permissions.FileIOPermission : System.Security.Permissions.FileIOPermissionAccess * System.Security.AccessControl.AccessControlActions * string -> System.Security.Permissions.FileIOPermission
Public Sub New (access As FileIOPermissionAccess, actions As AccessControlActions, path As String)
Public Sub New (access As FileIOPermissionAccess, control As AccessControlActions, path As String)
参数
- access
- FileIOPermissionAccess
FileIOPermissionAccess 枚举值的按位组合。
- actionscontrol
- AccessControlActions
AccessControlActions 枚举值的按位组合。
- path
- String
文件或目录的绝对路径。
例外
注解
此构造函数只允许为指定的文件或目录指定一个 FileIOPermissionAccess 值。 AddPathList使用 方法定义复杂权限。
参数 control
指定是否可以更改、查看或无法访问指定的 path
文件或目录的访问控制列表 (ACL) 。
重要
ACL) (访问控制列表描述对给定文件及其属性拥有或没有特定操作权限的个人或组。 更改或查看 ACL 的能力是一项重要权限,应谨慎授予。
适用于
FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[])
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
- Source:
- FileIOPermission.cs
使用对指定文件和目录的指定访问权限和对文件控制信息的指定访问权限初始化 FileIOPermission 类的新实例。
public:
FileIOPermission(System::Security::Permissions::FileIOPermissionAccess access, System::Security::AccessControl::AccessControlActions actions, cli::array <System::String ^> ^ pathList);
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 actions, 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
new System.Security.Permissions.FileIOPermission : System.Security.Permissions.FileIOPermissionAccess * System.Security.AccessControl.AccessControlActions * string[] -> System.Security.Permissions.FileIOPermission
Public Sub New (access As FileIOPermissionAccess, actions As AccessControlActions, pathList As String())
Public Sub New (access As FileIOPermissionAccess, control As AccessControlActions, pathList As String())
参数
- access
- FileIOPermissionAccess
FileIOPermissionAccess 枚举值的按位组合。
- actionscontrol
- AccessControlActions
AccessControlActions 枚举值的按位组合。
- pathList
- String[]
包含文件和目录的绝对路径的数组。
例外
注解
此构造函数只允许为指定的文件和目录指定一个 FileIOPermissionAccess 值。 AddPathList使用 方法定义复杂权限。
参数 control
指定是否可以更改、查看或无法访问指定的 path
文件或目录的访问控制列表 (ACL) 。
重要
ACL) (访问控制列表描述对给定文件及其属性拥有或没有特定操作权限的个人或组。 更改或查看 ACL 的能力是一项重要权限,应谨慎授予。