Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: IFileOperation - how to implement own overwrite dialog


This question is not answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Jan 21, 2016 1:48 PM Last Post By: Eric Holzer
Eric Holzer

Posts: 8
Registered: 5/7/10
IFileOperation - how to implement own overwrite dialog  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 20, 2016 1:45 PM
Hello,

I use IFileOperation for copy operation. It works fine. My problem is - I would like to implement my own overwrite question dialog.
I have defined with IFileOperation.Advise() the IFileOperationProgressSink methods. IFileOperationProgressSink.UpdateProgress works fine.
I think the proper place for testing if the destination item exists and showing the overwrite question is IFileOperationProgressSink.PreCopyItem. Unfortunatelly I can not find out what should the PreCopyItem return for skipping copied item.

Thanks for any hints,
Eric
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: IFileOperation - how to implement own overwrite dialog
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 20, 2016 2:40 PM   in response to: Eric Holzer in response to: Eric Holzer
Eric wrote:

I think the proper place for testing if the destination item exists
and showing the overwrite question is IFileOperationProgressSink.PreCopyItem.
Unfortunatelly I can not find out what should the PreCopyItem
return for skipping copied item.

I coulf be wrong, but I don't think IFileOperationProgressSink supports that.
If you return an error code from PreCopyItem(), the entire IFileOperation
is cancelled. This is clearly stated in the documentation:

IFileOperationProgressSink::PreCopyItem method
https://msdn.microsoft.com/en-us/library/windows/desktop/bb775737.aspx

Returns S_OK if successful, or an error value otherwise. In the case of an
error value, the copy operation **and all subsequent operations pending from
the call to IFileOperation** are canceled.

PreCopyItem() is meant for you to perform your own preparation logic before
a file is actually copied. IFileOperation itself performs the actual copy
afterwards, unless PreCopyItem() returns an error. PreCopyItem() gives you
some flags to tell you what IFileOperation will do with the file (fail if
the destination exists, overwrite if the destination exists, etc), but I
don't think you can change that behavior inside of PreCopyItem() itself.
It is just a status callback, it is not asking you for behavioral advice.

So, I don't think you can display your own overwrite prompt and skip individual
files using IFileOperationProgressSink. But I could be wrong. There is
very little information and examples available on this matter one way or
the other.

--
Remy Lebeau (TeamB)
Eric Holzer

Posts: 8
Registered: 5/7/10
Re: IFileOperation - how to implement own overwrite dialog  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 21, 2016 1:48 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:


Returns S_OK if successful, or an error value otherwise. In the case of an
error value, the copy operation **and all subsequent operations pending from
the call to IFileOperation** are canceled.

I think, I have overlooked it.

Thanks,
Eric
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02