Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

FileStream::SetAccessControl Method

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

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)
public:
void SetAccessControl(
	FileSecurity^ fileSecurity
)

Parameters

fileSecurity
Type: System.Security.AccessControl::FileSecurity

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

ExceptionCondition
ObjectDisposedException

The file is closed.

ArgumentNullException

The fileSecurity parameter is nullptr.

SystemException

The file could not be found or modified.

UnauthorizedAccessException

The current process does not have access to open the file.

While the FileStream class and SetAccessControl can be used on an existing file, consider using the File::SetAccessControl method as it is easier to use.

The SetAccessControl method applies access control list (ACL) entries to a file that represents the noninherited ACL list.

Caution noteCaution

The ACL specified for the fileSecurity parameter replaces the existing ACL for the file. To add permissions for a new user, use the GetAccessControl method to obtain the existing ACL, modify it, and then use SetAccessControl 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 Access Control List Entries.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.