Deleting folders in Documents and Settings

J

Jonas

Hi.

I am trying to delete unused user profiles, but i am not able to do this. I
think it has something to do with the SpecialFolder attribute? Does anyone
know how to delete files and folder under "Documents and Settings"
DirectoryInfo di = new DirectoryInfo(@"C:\Documents and Settings\Username");

di.Delete(true);
 
T

TerryFei

Hi,
Welcome to MSDN Newsgroup!

From my experience, this operation will need admin privilege. So please
help us confirm whether or not current user account owns admin privilege.
If not, you could use an admin account to log on and try this again.

If you have any questions or concerns, please let me know. I am standing by
to help you. Thanks again and have a nice day!

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
K

Kevin Yu [MSFT]

Hi Jonas,

You're getting an exception which says access denied, because there are
some read-only folders and files under the user's folder. Unlike deleting
in the windows UI, the Delete method cannot handle the files that are
read-only. So you have to make them writable first.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
K

Kevin Yu [MSFT]

You're welcome, Jonas.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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