System.IO.FileStream.SetAccessControl Method

Applies access control list (ACL) entries described by a System.Security.AccessControl.FileSecurity object to the file described by the current System.IO.FileStream object.

Syntax

public void SetAccessControl (System.Security.AccessControl.FileSecurity fileSecurity)

Parameters

fileSecurity
An object that describes an ACL entry to apply to the current file.

Remarks

While the System.IO.FileStream class and FileStream.SetAccessControl(System.Security.AccessControl.FileSecurity) can be used on an existing file, consider using the File.SetAccessControl(string, System.Security.AccessControl.FileSecurity) method as it is easier to use.

The FileStream.SetAccessControl(System.Security.AccessControl.FileSecurity) method applies access control list (ACL) entries to a file that represents the noninherited ACL list.

Note:

The ACL specified for the fileSecurity parameter replaces the existing ACL for the file. To add permissions for a new user, use the FileStream.GetAccessControl method to obtain the existing ACL, modify it, and then use FileStream.SetAccessControl(System.Security.AccessControl.FileSecurity) to apply it back to the file.

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

Requirements

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