DirectorySecurity Constructors

Definition

Initializes a new instance of the DirectorySecurity class.

Overloads

DirectorySecurity()

Initializes a new instance of the DirectorySecurity class.

DirectorySecurity(String, AccessControlSections)

Initializes a new instance of the DirectorySecurity class from a specified directory using the specified values of the AccessControlSections enumeration.

DirectorySecurity()

Initializes a new instance of the DirectorySecurity class.

public:
 DirectorySecurity();
public DirectorySecurity ();
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 DirectorySecurity object that is not based on an existing directory. You can then populate the object with access control information and apply it to a directory.

DirectorySecurity(String, AccessControlSections)

Initializes a new instance of the DirectorySecurity class from a specified directory using the specified values of the AccessControlSections enumeration.

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

Parameters

name
String

The location of a directory to create a DirectorySecurity object from.

includeSections
AccessControlSections

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

Exceptions

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

The name parameter is null.

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

The file specified in the name parameter was not found.

An I/O error occurred while opening the directory.

The name parameter is in an invalid format.

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 directory could not be found.

The name parameter specified a directory that is read-only.

-or-

This operation is not supported on the current platform.

-or-

The caller does not have the required permission.

Remarks

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

Security

FileIOPermission
for permission to access the directory specified by the name parameter. Associated enumerations: NoAccess , View Security action: Demand

Applies to