Rediger

Del via


FileIOPermission Constructors

Definition

Initializes a new instance of the FileIOPermission class.

Overloads

FileIOPermission(PermissionState)

Initializes a new instance of the FileIOPermission class with fully restricted or unrestricted permission as specified.

FileIOPermission(FileIOPermissionAccess, String)

Initializes a new instance of the FileIOPermission class with the specified access to the designated file or directory.

FileIOPermission(FileIOPermissionAccess, String[])

Initializes a new instance of the FileIOPermission class with the specified access to the designated files and directories.

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String)

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[])

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)

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

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)

Parameters

state
PermissionState

One of the PermissionState enumeration values.

Exceptions

The state parameter is not a valid value of PermissionState.

Examples

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

Remarks

Creates either fully restricted (None) or Unrestricted access to files and directories.

Applies to

FileIOPermission(FileIOPermissionAccess, String)

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

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)

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess enumeration values.

path
String

The absolute path of the file or directory.

Exceptions

The access parameter is not a valid value of FileIOPermissionAccess.

-or-

The path parameter is not a valid string.

-or-

The path parameter does not specify the absolute path to the file or directory.

Examples

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

Remarks

This constructor allows only one of the FileIOPermissionAccess values to be specified for the specified file or directory. Use the AddPathList method to define complex permissions.

Applies to

FileIOPermission(FileIOPermissionAccess, String[])

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

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())

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess enumeration values.

pathList
String[]

An array containing the absolute paths of the files and directories.

Exceptions

The access parameter is not a valid value of FileIOPermissionAccess.

-or-

An entry in the pathList array is not a valid string.

Remarks

This constructor allows only one FileIOPermissionAccess value to be specified for the specified files and directories. Use the AddPathList method to define complex permissions.

Applies to

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String)

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

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 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)

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess enumeration values.

actionscontrol
AccessControlActions

A bitwise combination of the AccessControlActions enumeration values.

path
String

The absolute path of the file or directory.

Exceptions

The access parameter is not a valid value of FileIOPermissionAccess.

-or-

The path parameter is not a valid string.

-or-

The path parameter does not specify the absolute path to the file or directory.

Remarks

This constructor allows only one FileIOPermissionAccess value to be specified for the specified file or directories. Use the AddPathList method to define complex permissions.

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.

Important

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. The ability to change or view an ACL is an important permission and should be granted with caution.

Applies to

FileIOPermission(FileIOPermissionAccess, AccessControlActions, String[])

Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs
Source:
FileIOPermission.cs

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 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())

Parameters

access
FileIOPermissionAccess

A bitwise combination of the FileIOPermissionAccess enumeration values.

actionscontrol
AccessControlActions

A bitwise combination of the AccessControlActions enumeration values.

pathList
String[]

An array containing the absolute paths of the files and directories.

Exceptions

The access parameter is not a valid value of FileIOPermissionAccess.

-or-

An entry in the pathList array is not a valid string.

Remarks

This constructor allows only one FileIOPermissionAccess value to be specified for the specified files and directories. Use the AddPathList method to define complex permissions.

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.

Important

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. The ability to change or view an ACL is an important permission and should be granted with caution.

Applies to