Source/NFX/IOMiscUtils.cs
/// <summary>
/// Creates directory and immediately grants it accessibility rules for everyone if it does not exists,
///  or returns the existing directory
/// </summary>
Creates directory and immediately grants it accessibility rules for everyone if it does not exists,
or returns the existing directory
Creates directory and immediately grants it accessibility rules for everyone if it does not exists or returns the existing directory
public static DirectoryInfo EnsureAccessibleDirectory(string path)
        {
          FileSystemAccessRule ausersRule = new FileSystemAccessRule(
                      new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), 
                      FileSystemRights.FullControl,
                      InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                      PropagationFlags.None,
                      AccessControlType.Allow);
          FileSystemAccessRule usersRule = new FileSystemAccessRule(
                      new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), 
                      FileSystemRights.FullControl,
                      InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                      PropagationFlags.None,
                      AccessControlType.Allow);
          FileSystemAccessRule adminsRule = new FileSystemAccessRule(
                      new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null), 
                      FileSystemRights.FullControl,
                      InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                      PropagationFlags.None,
                      AccessControlType.Allow);
          FileSystemAccessRule sysRule = new FileSystemAccessRule(
                     new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null), 
                     FileSystemRights.FullControl,
                     InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                     PropagationFlags.None,
                     AccessControlType.Allow);
          DirectorySecurity dirSec = new DirectorySecurity();
          dirSec.AddAccessRule(ausersRule);
          dirSec.AddAccessRule(usersRule);
          dirSec.AddAccessRule(adminsRule);
          dirSec.AddAccessRule(sysRule);
          return Directory.CreateDirectory(path, dirSec);
        }
public static DirectoryInfo EnsureAccessibleDirectory ( string path ) { FileSystemAccessRule ausersRule = new FileSystemAccessRule ( new SecurityIdentifier ( WellKnownSidType . AuthenticatedUserSid , null ) , FileSystemRights . FullControl , InheritanceFlags . ContainerInherit | InheritanceFlags . ObjectInherit , PropagationFlags . None , AccessControlType . Allow ) ; FileSystemAccessRule usersRule = new FileSystemAccessRule ( new SecurityIdentifier ( WellKnownSidType . BuiltinUsersSid , null ) , FileSystemRights . FullControl , InheritanceFlags . ContainerInherit | InheritanceFlags . ObjectInherit , PropagationFlags . None , AccessControlType . Allow ) ; FileSystemAccessRule adminsRule = new FileSystemAccessRule ( new SecurityIdentifier ( WellKnownSidType . BuiltinAdministratorsSid , null ) , FileSystemRights . FullControl , InheritanceFlags . ContainerInherit | InheritanceFlags . ObjectInherit , PropagationFlags . None , AccessControlType . Allow ) ; FileSystemAccessRule sysRule = new FileSystemAccessRule ( new SecurityIdentifier ( WellKnownSidType . LocalSystemSid , null ) , FileSystemRights . FullControl , InheritanceFlags . ContainerInherit | InheritanceFlags . ObjectInherit , PropagationFlags . None , AccessControlType . Allow ) ; DirectorySecurity dirSec = new DirectorySecurity ( ) ; dirSec . AddAccessRule ( ausersRule ) ; dirSec . AddAccessRule ( usersRule ) ; dirSec . AddAccessRule ( adminsRule ) ; dirSec . AddAccessRule ( sysRule ) ; return Directory . CreateDirectory ( path , dirSec ) ; }
Creates directory and immediately grants it accessibility rules for everyone if it does not exists,
or returns the existing directory
Creates directory and immediately grants it accessibility rules for everyone if it does not exists or returns the existing directory
//  "Authenticated Users", // "Users", // "Administrators", // "SYSTEM",
path
string