Inside and Out...

An attempt to understand technology better...

  Home  |   Contact  |   Syndication    |   Login
  160 Posts | 0 Stories | 12 Comments | 181 Trackbacks

News


WinToolZone - Spelunking Microsoft Technologies
I work as a developer on the Common Language Runtime (CLR) team, specifically in the areas of exception handling and CLR hosting.
Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Tag Cloud


Archives

Post Categories

Image Galleries

Links

Continuing from my last post, the same can be achieved using SetAccessRuleProtection as shown below:

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.AccessControl;
using System.IO;
using System.Security.Principal;

namespace AceInheritRemove
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get the object and its SecDescp
            DirectoryInfo dir = new DirectoryInfo("e:\\kgk\\test");
            DirectorySecurity sec = dir.GetAccessControl(AccessControlSections.All);

            sec.SetAccessRuleProtection(true, false);

            // Create a child folder with the explicit permissions only...
            DirectoryInfo info2 = new DirectoryInfo("e:\\kgk\\Test\\Child");
            info2.Create(sec);

            dir.SetAccessControl(sec);
        }
    }
}

posted on Tuesday, July 12, 2005 5:36 PM
Comments have been closed on this topic.