Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In one case, I was just writing a test application to enumerate all files on my system, and I get an "access denied" error for "C:\Documents and Settings" (which was returned by .NET when I said 'give me all subfolders in c:\').

Why is this happening?

FYI: I'm using Windows 7.

share|improve this question

c:\documents and settings doesn't -really- exist. It points straight to \users (A halfway decent filepath. I mean, \documents and settings? What were they THINKING?), it's not a real path, and is only there for compatibility reasons. You try to save a file at c:\documents and settings\username\hello.txt, it'll work, but it's only in there for compatibility reasons.

Deleting a file from a USB drive - is it one of those ones that can be set to read only? If so, is it?

share|improve this answer
Yeah, I was trying to say that my app actually got "c:\documents and settings" by calling Directory.GetDirectories(), so I'm confused why the API would return a directory that doesn't actually exist. Anyways, I'm also getting such errors when attempting to scan through other folders. – Christopher Nov 23 '09 at 21:06
It's not the only false folder in the filesystem, unfortunately. It exists, but only barely. I'm afraid it's just something you have to deal with. If the API didn't return it, older programs, or programs that rely on it returning it, would fail, wheras programs being written now can be written BETTER because of it ;) – Phoshi Nov 23 '09 at 21:15
have you tried to take OWNERSHIP of the ENTIRE C drive?? if you do this and set it to the user that you are running the program it should not get accesed denied. – mike Nov 24 '09 at 6:10
NO. That might have been acceptable back on XP, but Vista/7 are trying to change the whole we'll always have admin rights! ethos. You won't, and if you can't write your program without needing them you'd better have a damn good reason. – Phoshi Nov 24 '09 at 8:47
@mike - Very bad advice for way more reasons than I can put into a comment. – MDMarra Mar 8 '10 at 4:09

Whatever it is you are trying to write, I believe, like what Mike pointed out, you should "Take Ownership" of whatever drive / folder that your access has been denied. Even though you're the admin, if Administrator group is not defined in the list of users with access, you still cannot access the file / drive. Just "Take Owbership" of the file, problem solved. You would see in the folder properties that you don't have the access (Administrator group), that's why you were denied access of the folder / file / drive, etc.

Here's the link:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .