Επεξεργασία

Κοινή χρήση μέσω


FileSecurity Constructors

Definition

Initializes a new instance of the FileSecurity class.

Overloads

FileSecurity()

Initializes a new instance of the FileSecurity class.

FileSecurity(String, AccessControlSections)

Initializes a new instance of the FileSecurity class from a specified file using the specified values of the AccessControlSections enumeration.

FileSecurity()

Initializes a new instance of the FileSecurity class.

public:
 FileSecurity();
public FileSecurity ();
Public Sub New ()

Exceptions

The current operating system is not Microsoft Windows 2000 or later.

Remarks

Use this constructor when you want to create an empty FileSecurity object that's not based on an existing file. You can then populate the object with access control information and apply it to a file.

You can add access or audit rules to the FileSecurity object using the AddAccessRule method. You can remove access or audit rules using the RemoveAccessRule method.

Applies to

FileSecurity(String, AccessControlSections)

Initializes a new instance of the FileSecurity class from a specified file using the specified values of the AccessControlSections enumeration.

public:
 FileSecurity(System::String ^ fileName, System::Security::AccessControl::AccessControlSections includeSections);
public FileSecurity (string fileName, System.Security.AccessControl.AccessControlSections includeSections);
new System.Security.AccessControl.FileSecurity : string * System.Security.AccessControl.AccessControlSections -> System.Security.AccessControl.FileSecurity
Public Sub New (fileName As String, includeSections As AccessControlSections)

Parameters

fileName
String

The location of a file to create a FileSecurity object from.

includeSections
AccessControlSections

One of the AccessControlSections values that specifies the type of access control list (ACL) information to retrieve.

Exceptions

The fileName parameter is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

The specified path is invalid, (for example, it is on an unmapped drive).

The file specified in the fileName parameter was not found.

An I/O error occurred while opening the file.

path is in an invalid format.

The fileName parameter is null.

The current operating system is not Microsoft Windows 2000 or later.

The specified path, file name, or both exceed the system-defined maximum length.

The current system account does not have administrative privileges.

The file could not be found.

The fileName parameter specified a file that is read-only.

-or-

This operation is not supported on the current platform.

-or-

The fileName parameter specified a directory.

-or-

The caller does not have the required permission.

Remarks

This constructor retrieves the access control information for the specified file and then creates a FileSecurity object that encapsulates that information. You can then inspect, add, or delete the access control information for the specified file.

You can add access or audit rules to the FileSecurity object using the AddAccessRule method. You can remove access or audit rules using the RemoveAccessRule method.

Notes to Callers

The FileSecurity(String, AccessControlSections) constructor requires the current account to have administrative privileges. To create a new instance of the FileSecurity class for a specific file using an account that does not have administrative privileges, use the GetAccessControl() method.

Applies to