Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 130291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:55:29+00:00 2026-05-11T05:55:29+00:00

Running as an elevated admin on Vista SP1, my C# app tries to set

  • 0

Running as an elevated admin on Vista SP1, my C# app tries to set the following rule with the following code. No error is produced, but neither is any change on the directory’s ACL. What am I missing?

public static void Main( string args[] ) {     string dirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), 'Company'), 'Product' );     Directory.Create(dirPath);     _SetAcl(dirPath, 'Users', FileSystemRights.FullControl); }  private static void _SetAcl(string path, string identity, FileSystemRights rights) {     var info = new DirectoryInfo(path);     var acl = info.GetAccessControl();      var rule1 = new FileSystemAccessRule(identity, rights, AccessControlType.Allow);     bool modified;     acl.ModifyAccessRule(AccessControlModification.Reset, rule1, out modified);      var inheritanceFlags = InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit;     var rule2 = new FileSystemAccessRule(identity, rights, inheritanceFlags,                                         PropagationFlags.InheritOnly, AccessControlType.Allow);     acl.ModifyAccessRule(AccessControlModification.Add, rule2, out modified); } 

Update: Just add the following code as the last line of the _SetAcl method, and my code is good to go.

info.SetAccessControl(acl); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:55:30+00:00Added an answer on May 11, 2026 at 5:55 am

    To finish the process you must call DirectoryInfo.SetAccessControl() with the modified ACL.

    GetAccessControl() really returns a copy of the ACL. You’re free to modify it but it won’t take effect until you call SetAccessControl()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running an elevated UAC app. At one point in code, I want
My code is running elevated but nothing can see/execute c:\windows\system32\rstrui.exe (System Restore Point UI).
Running my script through Devel::NYTProf showed that the following portion of code took up
Running the following line in my script gives me a Permission denied error: $config_out
I have an app with a manifest that requires running as administrator, but part
Here is the scenario: 1. The app is already running as a local admin
I am trying to get my silverlight application running with elevated privileges in browser.
Running the following program on gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 and Intel(R) Core(TM)2 Duo CPU,
Running rails 3.2.3 with guard/spork/rspec/factory_girl and have the following in my spec helper: Spork.prefork
Running my finished Rails Tutorial app through Rails Best Practices got me a warning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.