473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 1397
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Colin Steadman | last post by:
I'm just starting out writing Python scripts (in PSP), and need to find the location of Windows special folders such as 'My Documents' and 'Desktop' so that I can save files in the right place. Is...
5
by: Rosa | last post by:
Hi, I'm trying to clear the TIF on Windows XP programmatically with the below code. This code works fine on any folder but the TIF. For some reason the atEnd() statements always defaults to true...
1
by: Ed | last post by:
Hello all. Hopefully I can get some help... I have created a little C# console app that we needed to delete certain user profiles from the documents and settings directory. But lo and behold I...
1
by: Xiaopeng Qu | last post by:
Hi, I installed DB2 8.1 Express on the WindowsXP, and when I begin to use it, I found DB2 creates many new folders in C:\Documents and Settings. It creats more and more folders every day. All...
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
5
by: George | last post by:
VB.net 2003 standard, XP windows home edition. Installed first application OK today. When I removed the application via Control Panel, there were no problems and the app folders were deleted. ...
12
by: wheels619 | last post by:
How can I get access for another user's special folder locations? A configuration file is stored in the users' appData folder and the program altering it will be ran under the admin.
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
1
by: Kyosuke18 | last post by:
Hi everyone, I have a problem in deleting a data that is connected on the database.. I tried this code but it shows me an error: Run-time error '-2147217900(80040e14)': Syntax error in string in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.