Export (0) Print
Expand All

FileStream.SetAccessControl Method

Note: This method is new in the .NET Framework version 2.0.

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
)
public void SetAccessControl (
	FileSecurity fileSecurity
)
public function SetAccessControl (
	fileSecurity : FileSecurity
)

Parameters

fileSecurity

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

Exception typeCondition

ObjectDisposedException

The file is closed.

ArgumentNullException

The fileSecurity parameter is a null reference (Nothing in Visual Basic).

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.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft