Deleting a user profile folder

I

Iceken

Hi,
In my app I need to delete several user profiles inside the Documents
and Settings folder.
But everytime i try Directory.Delete(path) I get a IOException with
"Access denied to path ..", however I can delete the folders using
windows explorer.

I'm logged in as an admin and the program runs under my account.
I've spent hours googling for a solution, but only found other people
with the same problem.


thanks in advance
 
W

Willy Denoyette [MVP]

Iceken said:
Hi,
In my app I need to delete several user profiles inside the Documents
and Settings folder.
But everytime i try Directory.Delete(path) I get a IOException with
"Access denied to path ..", however I can delete the folders using
windows explorer.

I'm logged in as an admin and the program runs under my account.
I've spent hours googling for a solution, but only found other people
with the same problem.


thanks in advance

Why re-inventing the wheel, use the command line tools built for this.
"net user username /delete "
deletes the user and it's profile.
You can use Process.Start to execute this command from code.

Willy.
 

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