Cannot delete directory with Directory. Deletepath, trueIf you are trying to recursively delete directory a and directory ab is open in Explorer, b will be deleted but you will get the error directory is not empty for a even though it is empty when you go and look. The current directory of any application including Explorer retains a handle to the directory. When you call Directory. Deletetrue, it deletes from bottom up b, then a. If b is open in Explorer, Explorer will detect the deletion of b, change directory upwards cd. Since the file system operates asynchronously, the Directory. Delete operation fails due to conflicts with Explorer. Incomplete solution. I originally posted the following solution, with the idea of interrupting the current thread to allow Explorer time to release the directory handle. Directory. Deletepath, true. IOException. Thread.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
September 2018
Categories |