Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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
1  
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
2  
@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: http://www.howtogeek.com/howto/windows-vista/add-take-ownership-to-explorer-right-click-menu-in-vista/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.