Delete(strDirPath, true) gives "the directory is not empty"

C

codeboy

I am using VS2008 to create a website. When I try to programmatically delete
a directory that is located within my website I will get an error. I am
trying to delete the directory using “System.IO.Directory.Delete(strDirPath,
true)â€. This is the message the error gives "the directory is not empty". I
found another entry titled “Directory.Delete of a non empty dir fails in
ASP.NET applicationâ€. In that posting Walter Wang says: “the folder is
locked by Visual Studio 2005 IDE if the folder is already shown in project
explorerâ€. Now that I am using VS2008 has this been changed? How can I test
my code? Please help me get past this problem.

Thanks
 
J

Juan T. Llibre

re:
!> How can I test my code?

Create an IIS virtual directory and test directory.delete with VS 2008 closed.

You can undo the IIS virtual directory when you've finished testing directory.delete.

When done testing directory.delete, open VS 2008 and continue testing the rest of the code.




===============
 
C

codeboy

This seems like a very cumbersome way of tying to handle the problem. I also
like to use the debugging tools. They will not be available if VS2008 is
closed. I need a way of testing my code within the development environment
without getting this error. How can I do this?
 
J

Juan T. Llibre

re:
!> This seems like a very cumbersome way of tying to handle the problem.

Given that VS 2008 locks the directory, it's the only way to do it.

re:
!> I also like to use the debugging tools. They will not be available if VS2008 is closed.

Of course not, but testing directory.delete doesn't really require a lot of debugging, does it ?
Do a simple test...and learn the correct way to handle directory deletions in IIS.

re:
!> I need a way of testing my code within the development
!> environment without getting this error. How can I do this?

File a bug report and wait for it to be fixed.

Also, you might want to check to see whether any files are in the directory.
You'll have to delete the files first before deleting the directory.

Also, are you sure the directory is not set as a read-only directory ?

See code to do that at :
http://www.eggheadcafe.com/conversation.aspx?messageid=33335128&threadid=33307218




===============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top