The below source codes allow you to give permissions to everyone for folder. When we need to upload or save some documents to a folder sometimes restricts the actions because of some permissions . In order to avoid this issue we can change permissions of a folder programmatically
var dInfo = new DirectoryInfo(@"C:\\MyFolder");
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
Enjoy coding….