473,405 Members | 2,404 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,405 software developers and data experts.

Problems with directory.delete

I'm getting an odd Exception thrown using Directory.Delete.

Expand|Select|Wrap|Line Numbers
  1. Directory.Delete(publicData + "Chatrooms/K" + kingd, true);
  2.  Directory.Delete(publicData + "Kingdoms/" + kingd, true);
  3.  
There are the two lines of code I have. First line works fine. Second line thriows an IO exception. None of the files are read only in the directory, and the directory exists. The odd thing is the files in the directory are getting deleted, but the directory itself is not. It remains. When the code hits a second time, then that direcory is removed.

Anyone ever experience this, or have any idea what could cause it. I use directory.delete in a few other placed, and I don't have problems with any of them. The fact the files are getting deleted by the command tells me they are not read only, or that it is a permissions problem.
Apr 23 '07 #1
1 1671
channaJ
67
I'm getting an odd Exception thrown using Directory.Delete.

Expand|Select|Wrap|Line Numbers
  1. Directory.Delete(publicData + "Chatrooms/K" + kingd, true);
  2.  Directory.Delete(publicData + "Kingdoms/" + kingd, true);
  3.  
There are the two lines of code I have. First line works fine. Second line thriows an IO exception. None of the files are read only in the directory, and the directory exists. The odd thing is the files in the directory are getting deleted, but the directory itself is not. It remains. When the code hits a second time, then that direcory is removed.

Anyone ever experience this, or have any idea what could cause it. I use directory.delete in a few other placed, and I don't have problems with any of them. The fact the files are getting deleted by the command tells me they are not read only, or that it is a permissions problem.
I think your problem is with the path you are specifying when calling the Delete method. Do a debug and get the complete path that is passed to the Delete method. If the path is wrong edit your code to pass the correct path.
Apr 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: John Caruthers | last post by:
HELP! This problem is driving me crazy. All other web sites that are being served out through this server are working, including sites and virtual directories that are under the Default Web...
2
by: Pete | last post by:
I've run into an interesting memory problem. I think I'm running out of heap space, but I'm not sure.... I'm creating two new arrays like such.... pImage = new UBYTE ; pImageTemp = new...
0
by: ALIEN | last post by:
Hi there I downloaded the file MySQL-4.1.0-0.src.rpm. I try to build it by entering: rpm --rebuild MySQL-4.1.0-0.src.rpm --target=i686 (i have an AthlonXP so the optimised code should work...
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
2
by: Juby | last post by:
I'm creating a script for our website which will function as something of a docment manager. The backend features an option to create a new directory in the uploads subdirectory. The problem is,...
7
by: Anil Gupte | last post by:
Private Sub mnu2Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu2Exit.Click Dim fDir As String = Path.GetDirectoryName(L3Global.VideoFileName) ...
6
by: Charlie Bear | last post by:
i'm really stuck with this one can anyone help! i have a website that uses c#. it creates a series of directories and files from an xml source. when the xml changes, the directory that the...
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...
3
by: Steph | last post by:
hello, i ve a probleme when deleting a directory and when i want create file immediatly after. 1) Directory.Delete(myPath, true); 2) TextWriter sw = new StreamWriter(myPath +"test.aspx"); i...
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: 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
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
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...
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.