5.23. Manipulate the Access Control Lists of a File or Directory

Problem

You want to modify the access control list (ACL) of a file or directory in the computer.

Solution

Use the GetAccessControl and SetAccessControl methods of the File or Directory class.

How It Works

The .NET Framework includes support for ACLs for resources such as I/O, registry, and threading classes. You can retrieve and apply the ACL for a resource by using the GetAccessControl and SetAccessControl methods defined in the corresponding resource classes. For example, the File and Directory classes define both these methods, which let you manipulate the ACLs for a file or directory.

To add or remove an ACL-associated right of a file or directory, you need to first retrieve ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.