Click here to Skip to main content
13,593,169 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

11.8K views
107 downloads
4 bookmarked
Posted 31 Jan 2015
Licenced CPOL

AccessControl.FileSystemRights Permissions Table

, 31 Jan 2015
Rate this:
Please Sign up or sign in to vote.
A quick C# reference for FileSystemRights enumeration in table format.

Introduction

The other day, I went to go use the FileSystemRights enum and quickly got confused with all the different kinds of windows file permissions - I'm pretty sure I'm not alone.  Some of the enums only have a single permission flag while others contain multiple flags.  I hope this short reference will help understand the breakdown.

Enumerating the Enum  

To generate a list of flags that make up FileSystemRights, the following was used:  

foreach (var f in Enum.GetValues(typeof(FileSystemRights)))
{
    Console.WriteLine(f.ToString().PadLeft(28) + Convert.ToString((int)f, 2).PadLeft(32, '0'));
}

the output:


(diagram 1)

Some values appear to be displayed twice but that is a side effect of the generating code.  The reason is because some items have the same bitflag and when ToString() looks them up it returns the first match.  e.g. ReadData and ReadDataListDirectory are both listed with the value 1. This is cleaned up in the next table as "ReadDataListDirectory/ReadData".

Cleaning up the table

Here is a beautified version of the above:  (Removed empty columns, rearranged, combined duplicates, added headers, and highlighted for optimal viewing.)


(diagram 2)

From the above table, we can see that there are individual distinct permissions (bottom 13 rows), and sets of permissions (top 5 rows). 

Summarizing the Sets

Here are all the 17 different enumerations for FileSystemRights. On the left are the distinct values and on the right are friendly multi-flag sets.


(diagram 3)

Read and Write contain an independent set of permissions - nothing is related.  ReadAndExecute is the same as Read but with Execute as well.  Modify basically contains Write ReadAndExecute + Delete.  And finally there is FullControl, which has everything. FullControl is like Modify but also adds DeleteSubdirectoriesAndFiles +ChangePermissions + TakeOwership +  [one more unknown bit].

For most needs, the multi-flag sets (WriteReadReadAndExecuteModify, and FullControl) will be all that is needed. However, for more advanced needs, flags can be OR-ed together.  (e.g. Read | Delete)

Points of Interest

  • The permissions match up with Windows NTFS - to be expected I guess.  There are 14 distinct flags in FileSystemRights ([full] not shown) and in explorer's permissions there are 14 as well.  Furthermore, with the exception of Special Permissions, there are also the same 5 permission sets.
  • FullControl has one additional flag set with no matching individual flag. (see diagram 2) 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ryan S White
Help desk / Support
United States United States
Ryan White is an IT Coordinator, currently living in Pleasanton, California.

He earned his B.S. in Computer Science at California State University East Bay in 2012. Ryan has been writing lines of code since the age of 7 and continues to enjoy programming in his free time.

You can contact Ryan at s u n s e t q u e s t -A-T- h o t m a i l DOT com if you have any questions he can help out with.

You may also be interested in...

Comments and Discussions

 
GeneralLittle correction Pin
John B Oliver23-Feb-15 10:25
memberJohn B Oliver23-Feb-15 10:25 
GeneralRe: Little correction Pin
Ryan S White23-Feb-15 14:33
professionalRyan S White23-Feb-15 14:33 
GeneralGot my 5 ! Pin
Ashokkumar.Ramraj1-Feb-15 21:24
memberAshokkumar.Ramraj1-Feb-15 21:24 
GeneralRe: Got my 5 ! Pin
Ryan S White2-Feb-15 6:20
professionalRyan S White2-Feb-15 6:20 
GeneralRe: Got my 5 ! Pin
Ashokkumar.Ramraj2-Feb-15 18:15
memberAshokkumar.Ramraj2-Feb-15 18:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.180618.1 | Last Updated 31 Jan 2015
Article Copyright 2015 by Ryan S White
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid