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

My code is running elevated but nothing can see/execute c:\windows\system32\rstrui.exe (System Restore Point UI).
I'm running a Silverlight 4 app with elevated trust out of browser and cannot
Running into a problem where on certain servers we get an error that the
Running FxCop on my code, I get this warning: Microsoft.Maintainability : 'FooBar.ctor is coupled
When running my application I sometimes get an error about too many files open
Running a rails site right now using SQLite3. About once every 500 requests or
running git instaweb in my repository opens a page that says 403 Forbidden -
Running OS X Leopard an MacBook Pro from Jan. 2008. I used to run
Running a ServiceHost with a single contract is working fine like this: servicehost =
Running ipconfig /all shows a Teredo Tunneling Pseudo-Interface. What is that? Does this have

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.