471,350 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Deleting folders in Documents and Settings

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);
Dec 7 '05 #1
5 1321
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.)

Dec 8 '05 #2
Hi Terry.

The operation is done with local admin privileges.
""TerryFei"" <v-******@online.microsoft.com> wrote in message
news:ef****************@TK2MSFTNGXA02.phx.gbl...
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.)

Dec 8 '05 #3
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."

Dec 9 '05 #4
Thank you Kevin, you solved my problem.
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:d9**************@TK2MSFTNGXA02.phx.gbl...
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."

Dec 9 '05 #5
You're welcome, Jonas.

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

Dec 10 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Colin Steadman | last post: by
1 post views Thread by Ed | last post: by
6 posts views Thread by Martin Bischoff | last post: by
12 posts views Thread by wheels619 | last post: by
3 posts views Thread by Kimera.Kimera | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.