Programmatically check directory permissions

  • Thread starter Thread starter Steven
  • Start date Start date
S

Steven

Does anyone know if there is a way to check the access
permissions of different users using C#? I need to know
if a user has full control or if they have read only
access or none to a certain directory. I have seen
different ways to set the permissions but none to read
them. Any help would be appreciated. Thanks in advance.
 
Well, honestly, the easiest way is to try to examine the contents of the
directory. If that works, create a temp file in the directory and delete
it. If you can do all three, you have full control. If you cannot create
the file, but you can read the contents, you have read access. If you
cannot read the directory, you have no access.

Just make sure to catch the exceptions and handle them appropriately.

I suppose you could inspect the ACLs on the directory itself, but it would
be harder than doing the things above.

--- Nick
 
Thanks for your help Nick. I have been checking the directory
permissions using the example that you provided. Do you know if there is
a way to programatically check the ACLS or if the .NET framework
provides any classes to check the ACLS?



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Thanks for your help Nick. I have been checking the
directory
permissions using the example that you provided. Do you
know if there is
a way to programmatically check the ACLS or if the .NET
framework
provides any classes to check the ACLS?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top