I believe I can use the Invoke Method to assign file permissions to a Directory/File Share
I have a variable set as
New FileSystemAccessRule(currentUserIdentity.Name, FileSystemRights.Read, InheritanceFlags.ObjectInherit Or InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow)
How do I assign these permissions to a Directory/File Share using the Invoke Method as I cannot seem to get the correct match of Target Type/Target Object and Method
Many thanks
@gary.cobden
Try these steps:
- Target Type: Choose the appropriate target type based on the object you are working with. For file permissions, you can typically use the
System.IO.DirectoryInfo
or System.IO.FileInfo
types. Select the appropriate type based on whether you are assigning permissions to a directory or a file.
- Target Object: Provide the directory or file object to which you want to assign the permissions. This can be the path of the directory or file, or the actual
DirectoryInfo
or FileInfo
object.
- Method: The method you need to use is
GetAccessControl
to retrieve the existing access control settings, and then SetAccessControl
to apply the modified permissions.
@raja.arslankhan
Thanks for the above but I get the following
‘DirectoryInfo’ does not have a public static method named ‘SetAccessControl’ matching the parameter types, generic type arguments, and generic type constraints supplied to Invoke Method ‘Invoke Method ACL’
Same if I use FileInfo as TargetType