Directory.Delete problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry

    Directory.Delete problem

    In short, I'm getting an IOException "Directory is not empty" if I have a
    Windows Explorer window open and have a subdirectory selected in the tree
    view.

    For example, I have a directory path of "C:\TestDelete\ Sub1". I have
    Windows Explorer open and I have "Sub1" selected in the tree view. There
    are no files in any of the directories and none are read-only. If I then
    call:

    Directory.Delet e(@"C:\TestDele te", true); // recursive delete

    it will throw an IOException. If I have any other directory selected it
    works fine. Is this a bug, or just an unfortunate interaction with
    Explorer?

    What looks to be happening is the Delete function deletes "Sub1" and
    Explorer moves the selection down to the "TestDelete " directory, and I'm
    assuming is locking the tree during the selection move when the Delete
    function tries to delete the parent.

    Anyone have any thoughts on this? There's really no reason it should fail.

    Thanks.


Working...