开发者

Windows Explorer Shell Extension: recursive delete via ITransferSource::RemoveItem?

I'm implementing a Windows Explorer Shell Extension for a networked file system on Windows 7, and I've hit a snag while implementing the Delete functionality.

Let's say my remote filesystem hierarchy is as follows:

Dir1
+-Dir2
| +-A
| +-B
+-C

My understanding is that you need to implement ITransferSource::RemoveItem (which I've done), but I expected to be called recursively from the furthest child in the filesystem tree first (i.e. a depth-first recursive traversal):

(A, B, Dir2, C, Dir1)

What happens is that I'm called for the root first, then each children, iteratively:

(Dir1, C, Dir2, A, B)

This is a bit weird to me since the Shell will already recursively iterate through all items to be deleted in order to show the progress bar for the operation (the "discovering items" dialog). My remote filesystem does not support deleting non-empty directories; as far as I know, the local filesystem on Windows has the same limitation. I could not find any hints on MSDN about changing the iteration order.

I presume that the actual iteration order varies depending on the creation order of the items in the filesystem.

When implementing this interface method, you can return COPYENGINE_S_DONT_PROCESS_CHILDREN if you recurse and delete entire trees yourself, but I think this will not allow the user to Cancel a deletion in progress (like the standard Explorer shell would). I consider this a sub-optimal solution, but it may have to do if I don't find a better solution.

My fir开发者_运维知识库st thought was to queue up the non-empty directory deletion requests for later, but I don't think this will work, because the extension will not know when the Delete operation for all children of a directory is completed. I could also spawn a thread to delete these items "later" but that's almost certain to create weird unexplained behaviors and crashes.

So, I guess my question is, what is the proper way to implement the Delete operation in a Windows 7 Shell Extension?

PS: as you can probably tell, Windows Shell Extensions are a completely new topic for me, so I apologize in advance if the question is incomplete; I will refine my question as needed.

Thanks!


From the documentation it looks like the EnterFolder and LeaveFolder methods will help you out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜