System.IO.DirectoryInfo.SetAccessControl Method

Applies access control list (ACL) entries described by a System.Security.AccessControl.DirectorySecurity object to the directory described by the current System.IO.DirectoryInfo object.

Syntax

public void SetAccessControl (System.Security.AccessControl.DirectorySecurity directorySecurity)

Parameters

directorySecurity
An object that describes an ACL entry to apply to the directory described by the path parameter.

Remarks

An access control list (ACL) describes individuals and/or groups who have, or do not have, rights to specific actions on the given file or directory. For more information, see ACL Technology Overview and How to: Add or Remove an Access Control List Entry.

The DirectoryInfo.SetAccessControl(System.Security.AccessControl.DirectorySecurity) method applies ACL entries to a file that represents the noninherited ACL list.

Note:

The ACL specified for directorySecurity replaces the existing ACL for the directory. To add permissions for a new user, use the erload:System.IO.DirectoryInfo.GetAccessControl method to obtain the existing ACL, and modify it.

The DirectoryInfo.SetAccessControl(System.Security.AccessControl.DirectorySecurity) method persists only System.Security.AccessControl.DirectorySecurity objects that have been modified after object creation.  If a System.Security.AccessControl.DirectorySecurity object has not been modified, it will not be persisted to a file.  Therefore, it is not possible to retrieve a System.Security.AccessControl.DirectorySecurity object from one file and reapply the same object to another file.

To copy ACL information from one file to another:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0