By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,985 Members | 1,712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,985 IT Pros & Developers. It's quick & easy.

Problems with directory.delete

P: 1
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
Share this Question
Share on Google+
1 Reply


P: 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

Post your reply

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