0

Possible Duplicate:
Detect if program is running with full administrator rights

How to check what rights the user?

I need to chek write access to C:/Windows/SomeFolder

Community
  • 1
  • 1
Dcow
  • 1,413
  • 1
  • 19
  • 42
  • 1
    [See this question](http://stackoverflow.com/questions/4230602/detect-if-program-is-running-with-full-administrator-rights). [And this one](http://stackoverflow.com/questions/1453497/discover-if-user-has-admin-rights). – Cornstalks Nov 25 '12 at 16:39
  • sorry, my mistake. found solution – Dcow Nov 25 '12 at 19:19
  • 1
    @Cornstalks Neither of those questions appear to be related. They concern how to find out whether or not the current user is an admin. This question asks about permissions of the current user to write to a folder. And those are quite different things. – David Heffernan Nov 25 '12 at 20:03

1 Answers1

3

The best way to do it is to write to that folder (i.e. create a file in there or whatever your end-goal is). If that fails, the error code should indicate what went wrong — you might not have enough rights or no disk space left etc. Checking for privileges before doing something is like asking if you can ask — it is always better to just ask. Not to mention the race condition where you could have rights to write and it's gone before you actually do write.