473,385 Members | 1,757 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,385 software developers and data experts.

Directory.Delete method

Hi,

I am attempting to delete Profile folders from C:\Documents and
Settings\. I am receiving a Permission denied error when using the
Directory.Delete method. Here is my code. Is there any way around
this? I am a Local Administrator on the PC where I am running the
application. I have tried rebooting and I am not logged in as the user
I am trying to delete. The folder is not empty and contained both
hidden files and folders as well as read only folders. As part of my
troubleshooting, I disabled Read only and (unhided???) all the folders.
Thanks

Imports System
Imports System.IO

Public Class Test
Public Shared Sub Main()
' Specify the directories you want to manipulate.
Dim path As String = "c:\Documents and Settings\ctx1"

Try
'This operation will not be allowed because there are
subdirectories.
Directory.Delete(path, True)
Catch e As Exception
MsgBox(e.Message.ToString)
End Try
End Sub
End Class

May 10 '06 #1
7 2003
When I attempt to uncheck Read Only on C:\Documents and
Settings\ctx1\Application Data, it keeps coming back. Any way for me
to set this programatically then delete the folder. I know you can set
attributes for files but what about for folders?

May 10 '06 #2
Yes, you can do this using the DirectoryInfo class the same as you would use
the FileInfo class.
--
KMG Software, Inc.
Thinking Beyond, Above, and Before
http://www.kmgsoftware.com
"Brian Cahill" wrote:
When I attempt to uncheck Read Only on C:\Documents and
Settings\ctx1\Application Data, it keeps coming back. Any way for me
to set this programatically then delete the folder. I know you can set
attributes for files but what about for folders?

May 11 '06 #3
Thanks for your help but setting the attributes and then deleting did
not work. Any other ideas?

May 11 '06 #4
You can't do this through the file system, because that folder represents an
OS entity (a User Profile).

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Brian Cahill" <bc*****@wfs-ops.org> wrote in message
news:11**********************@q12g2000cwa.googlegr oups.com...
Thanks for your help but setting the attributes and then deleting did
not work. Any other ideas?

May 11 '06 #5
You may find the following article somewhat helpful:

http://technet2.microsoft.com/Window....mspx?mfr=true

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Brian Cahill" <bc*****@wfs-ops.org> wrote in message
news:11**********************@q12g2000cwa.googlegr oups.com...
Thanks for your help but setting the attributes and then deleting did
not work. Any other ideas?

May 11 '06 #6
BTW, from what I've been reading, it can be done programmatically through
WMI. So, you ought to be able to do it in .Net by using the
System.Management namespace classes. How, I don't know.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Brian Cahill" <bc*****@wfs-ops.org> wrote in message
news:11**********************@q12g2000cwa.googlegr oups.com...
Thanks for your help but setting the attributes and then deleting did
not work. Any other ideas?

May 11 '06 #7
Thanks, I'll give that a shot.

May 11 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
3
by: James | last post by:
..2003 have a filesystemwatcher ... does it have a directorysystemwatcher ? What i need is to watch whether directory is deleted ? i assume filesystemwatcher delete method is for file, not...
23
by: **Developer** | last post by:
Is there an easy way to copies all files in a directory into another directory? What about coping subdirectories too? Thanks in advance for any info
0
by: Brian Cahill | last post by:
Hi, I am attempting to delete Profile folders from C:\Documents and Settings\. I am receiving a Permission denied error when using the Directory.Delete method. Here is my code. Is there any...
1
by: zacks | last post by:
I am trying to delete a directory with the Directory.Delete method, specifying True for the second parameter, to indicate all subfolders as well. But an exception is thrown indicating I do not have...
11
by: comp.lang.php | last post by:
Once again, I thought my class method deleteZip() would do the trick, but it never deletes any .zip* file found in a directory: /** * Delete any latent ZIP files found in this album. This...
5
by: Olivier GIL | last post by:
Hello, The method Directory.Delete(path, true) of .NET 2.0 called from within a web app does not work correctly if the initial directory is not empty : all the files inside the root directory...
3
by: Koliber (js) | last post by:
sorry for my bad english when I fire up (from my c# code) a standard "file - save as " dialog, and when chosen location is a shered local network directory, where I do have rights to create...
6
by: falconsx23 | last post by:
I am trying to write a code for a Phone Directory program. This program is suppose to allow the user to enter a name or directory and then program can either add, save or even delete an entry. Also...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.