Directory recursion

R

Rex the Strange

Hi everyone,

Surely this isn't that hard:

I'm trying to create a routine which is recursive across the entire
directory structure on a designated drive (from the root directory
through every folder on the drive - system, hidden, the lot).

And I'm getting, when I try:

directoryinfo.getdirectories

on a system folder, the dreaded "unauthorized access exception." I
have set the UAC settings to "requireAdministrator" as one post
suggested. I am running as an administrator (I'm the only user of this
computer). Some posts suggest "impersonation" - but I haven't found an
easy explanation of what this is all about.

Who do I have to kill to get past this? Please help?

tia,
rts
 
M

Mike Lovell

Surely this isn't that hard:
I'm trying to create a routine which is recursive across the entire
directory structure on a designated drive (from the root directory
through every folder on the drive - system, hidden, the lot).

And I'm getting, when I try:

directoryinfo.getdirectories

on a system folder, the dreaded "unauthorized access exception." I
have set the UAC settings to "requireAdministrator" as one post
suggested. I am running as an administrator (I'm the only user of this
computer). Some posts suggest "impersonation" - but I haven't found an
easy explanation of what this is all about.

Who do I have to kill to get past this? Please help?

You shouldn't need to go down impersonation or UAC routes if you're running
as administrator.

What "system" folder are you talking about here?

Also Could you post the code/function?
 
P

Peter Duniho

Rex said:
Hi everyone,

Surely this isn't that hard:

I'm trying to create a routine which is recursive across the entire
directory structure on a designated drive (from the root directory
through every folder on the drive - system, hidden, the lot).

And I'm getting, when I try:

directoryinfo.getdirectories

on a system folder, the dreaded "unauthorized access exception." I
have set the UAC settings to "requireAdministrator" as one post
suggested. I am running as an administrator (I'm the only user of this
computer). Some posts suggest "impersonation" - but I haven't found an
easy explanation of what this is all about.

Who do I have to kill to get past this? Please help?

If you don't have the rights to view the directory, you don't have the
rights. This really has nothing to do with .NET, but the bottom line
is: if you want to be able to view every single directory on the disk,
you have to be executing the code with the privileges of a user that has
security access to every single directory on the disk.

Simply running with admin rights may well not be enough, depending on
how the permissions on the disk are configured.

Pete
 
G

Göran Andersson

Rex said:
Hi everyone,

Surely this isn't that hard:

I'm trying to create a routine which is recursive across the entire
directory structure on a designated drive (from the root directory
through every folder on the drive - system, hidden, the lot).

And I'm getting, when I try:

directoryinfo.getdirectories

on a system folder, the dreaded "unauthorized access exception." I
have set the UAC settings to "requireAdministrator" as one post
suggested. I am running as an administrator (I'm the only user of this
computer). Some posts suggest "impersonation" - but I haven't found an
easy explanation of what this is all about.

Who do I have to kill to get past this? Please help?

tia,
rts

Your code is probably trying to do something like looking inside the
trashcan folder.

Check the attributes of each folder. If it's a hidden system folder,
just skip it.
 
J

Jeff Johnson

Your code is probably trying to do something like looking inside the
trashcan folder.

Actually, my money's on System Volume Information. Locked down tight as a
drum.
 

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

Top