Windows Phone Developers

Tuesday, June 21, 2011

How to Change Permission of Folder in Visual Basic / C#

VB.NET Set Folder Permission / C# Set Folder Permission


In this snippet we create a new directory and set the permission of it to Fullcontrol using ACL.

private static void ChangePermissionOfDir()
        {
            //Folder
            DirectoryInfo NewDir = Directory.CreateDirectory(@"C:\Temp\Te21");

            DirectorySecurity dSecur = NewDir.GetAccessControl();

            FileSystemAccessRule fAccess = new FileSystemAccessRule("Everyone",FileSystemRights.FullControl,AccessControlType.Allow  );


            dSecur.AddAccessRule(fAccess);

            NewDir.SetAccessControl(dSecur);
 
    
        }
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment