473,569 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:\Documen ts and Settings\Userna me");

di.Delete(true) ;
Dec 7 '05 #1
5 1405
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.m icrosoft.com> wrote in message
news:ef******** ********@TK2MSF TNGXA02.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.mic rosoft.com> wrote in message
news:d9******** ******@TK2MSFTN GXA02.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
5261
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 there any method I can use in Python to get these? If I were doing this in VBScript it'd be: Dim WSHShell Set WSHShell =...
5
16765
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 and no files are deleted in the folder. The peculiarity of this issue is that the files/subfolders cannot be seen through the windows explorer...
1
1941
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 get an error. Access to the path 'path' is denied. I have deleted the folders manually with no problems and I have verified that the console...
1
1731
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 new folders has name like: "db2admin", "db2admin.MACHINENAME", "db2admin.MACHINENAME.001", "db2admin.MACHINENAME.002", ... Can any one help me with...
6
4548
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 restarts and all active sessions are terminated. This error is also described in detail here:...
5
2672
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. But when I installed the app from a CD-ROM (Release folder is in D:), when I remove the app in Control Panel these problems occur: Control Panel...
12
7995
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
2866
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, removing all the files/folders inside it. The problem i am having is that i can only delete files in the Windows/Temp folder, and i can't delete...
1
1712
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 query expression 'ID=". Here is the code that i did: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim ab As String cn.Open...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7673
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.