how to set access control list(acl) permission

how to set access control list(acl) permission

 Private Function check(ByVal FileName As String, ByVal Account As String, ByVal UserRights As String)
        Dim Rights As FileSystemRights = FileSystemRights.FullControl
        Dim AccessRule As FileSystemAccessRule = New FileSystemAccessRule(Account, Rights, InheritanceFlags.None, PropagationFlags.NoPropagateInherit, AccessControlType.Allow)
        Dim info As DirectoryInfo = New DirectoryInfo(FileName)
        Dim Security1 As DirectorySecurity = info.GetAccessControl(AccessControlSections.Access)
        Dim ss As New SecurityIdentifier("S-1-5-32-544")
        Dim Result As Boolean = False
        Security1.ModifyAccessRule(AccessControlModification.Set, AccessRule, Result)
        Dim iFlags As InheritanceFlags = InheritanceFlags.ObjectInherit
        If True Then iFlags = InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit
        AccessRule = New FileSystemAccessRule(Account, Rights, iFlags, PropagationFlags.InheritOnly + PropagationFlags.NoPropagateInherit, AccessControlType.Allow)
        Result = Security1.ModifyAccessRule(AccessControlModification.Add, AccessRule, True)
        Return True
    End Function        

error is from this line   info.SetAccessControl(Security1)

and says "Unauthorized access"  Please give me a right solution for this...Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You already have the solution I think. You need permissions to set the permissions. What account are you using to run this code and on what operating system?
bensamAuthor Commented:
Its windows 7 x86 Ultimate. Its not admin account.....
That is the problem you need to sort. Heard of UAC Elevation?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bensamAuthor Commented: please tell me is ther anything wrong in my code?
I dont see anything wrong in the code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.