Reputation: 35
I need to allow edit files in directory to users. Directory and files in it was created with admin priviliges. So, when user try to resave files in it - exception. What I can do in this case? Or may be exist a way to create directory with specific rights? I am using C# .Net 4.0
Upvotes: 0
Views: 82
Reputation: 192
Grand access for all users (with subfolders) like this:
DirectoryInfo dInfo;
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
Upvotes: 1