GetAccessControl
will get the FileSecurity
.
From MSDN:
Represents the access control and audit security for a file. [...] This class represents access and audit rights as a set of rules.
A FileSecurity
is not dependent on a particular file, so you can use one FileSecurity
on multiple files to set identical access and audit rights.
This is why you need to specify the filename.
An alternative would be to use the FileInfo
class.
var fileInfo = new FileInfo(filename);
var security = fileInfo.GetAccessControl();
// [...]
fileInfo.SetAccessControl(security);
The constructors from MSDN:
FileSecurity()
Will create an empty FileSecurity
object.
FileSecurity(String, AccessControlSections)
Creates an empty FileSecurity
object from the specified file using the specified values of the AccessControlSections
enumeration.