I need to give the folder "Temporary ASP.NET Files" a write permission using c#... and I use this code to give it the access
DirectoryInfo d1 = new DirectoryInfo(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "Temporary ASP.NET Files"));
DirectorySecurity md1 = d1.GetAccessControl();
string user_1 = fa.TextGuestDomain + "\\" + fa.TextGuestUser;
md1.AddAccessRule(new FileSystemAccessRule(user_1, FileSystemRights.FullControl,InheritanceFlags.ObjectInherit,PropagationFlags.InheritOnly, AccessControlType.Allow));
I know your pain - filesystem ACLs are a pain to modify and even if it seems to work, it might break in some circumstances. In your case, there's a simple solution, fortunately.
The problem lies with
PropagationFlags.InheritOnly. This means that this permission is only applied to items that inherit permissions - e.g. you are granting rights only for the files in this directory and not in any subdirectories.
To grant directory rights that inherit "normally" (i.e. propagate to subdirectories and all files), use the following values for InheritanceFlags and PropagationFlags:
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit and