Discussion:
Overwrite confirmations in NSE using IFileOperation
(too old to reply)
Vladimir Granitsky
2009-09-29 08:42:04 UTC
Permalink
Hi there,

I am developing a NSE, which is basically a virtual file system folder, that
is, it is expected to behave much like a real file system folder. I've
implemented menu commands and drag and drop operations using the file
operation engine of Vista (IFileOperation), so I've implemented IDropTarget,
ITransferDestination and ITransferSource etc.

Now, I want to support overwrite confirmations. I think this must be done
through ITransferAdviseSink and I expect my
ITransferDestination::Advise to be called in order to enable the feedback.
The problem is that my
ITransferDestination::Advise method never gets called.

Can somebody give me an idea why this could be or what else I may need to
support overwrite confirmations ?

Thanks in advance
bviksoe
2009-09-29 15:47:25 UTC
Permalink
Post by Vladimir Granitsky
Hi there,
I am developing a NSE, which is basically a virtual file system folder, that
is, it is expected to behave much like a real file system folder. I've
implemented menu commands and drag and drop operations using the file
operation engine of Vista (IFileOperation), so I've implemented IDropTarget,
ITransferDestination and ITransferSource etc.
Now, I want to support overwrite confirmations. I think this must be done
through ITransferAdviseSink and I expect my
ITransferDestination::Advise to be called in order to enable the feedback.
The problem is that my
ITransferDestination::Advise method never gets called.
Can somebody give me an idea why this could be or what else I may need to
support overwrite confirmations ?
Thanks in advance
The FileOperation engine will handle overwrite prompts just fine if
you implement the interfaces you describe and handle the flags passed,
such as the TSF_OVERWRITE_EXIST flag in
ITransferDestination::CreateItem. Carefully return HRESULT_FROM_WIN32
(ERROR_FILE_EXISTS) and HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) when
appropriate.

Your items will be queried for properties such as PKEY_FileName and
PKEY_DateModified in order to fill out the prompt dialog - or probably
whatever you define in PKEY_PropList_FileOperationPrompt.

The mistake I made when implementing this was actually to create the
FileOperation component with the FOF_NOCONFIRMATION flag when I needed
to paste files, which obviously supresses prompts! D'oh.

You can find my sample code here:
http://www.viksoe.dk/code/flickrdrive.htm


regards,
bjarke
Vladimir Granitsky
2009-10-03 08:49:22 UTC
Permalink
Thanks bjarke,

I tried this before, and now after few days of debugging I found that the
problem is because my ParseDisplayName does not validate the existence of
the item. The shell calls ParseDisplayName to find a name of non-existing
item to suggest in the "keep both items" dialog option -"MyDocument (1).doc"
etc. It makes 999 attempts (1), (2) ... (999) and then fails the operation.
After I made it to return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) for
non-existing items the dialog appeared.

As you suggest, it queties for these properties and in addition I had to
provide PKEY_ItemNameDisplay and PKEY_ItemPathDisplay.

Thanks again.
Post by Vladimir Granitsky
Hi there,
I am developing a NSE, which is basically a virtual file system folder, that
is, it is expected to behave much like a real file system folder. I've
implemented menu commands and drag and drop operations using the file
operation engine of Vista (IFileOperation), so I've implemented IDropTarget,
ITransferDestination and ITransferSource etc.
Now, I want to support overwrite confirmations. I think this must be done
through ITransferAdviseSink and I expect my
ITransferDestination::Advise to be called in order to enable the feedback.
The problem is that my
ITransferDestination::Advise method never gets called.
Can somebody give me an idea why this could be or what else I may need to
support overwrite confirmations ?
Thanks in advance
The FileOperation engine will handle overwrite prompts just fine if
you implement the interfaces you describe and handle the flags passed,
such as the TSF_OVERWRITE_EXIST flag in
ITransferDestination::CreateItem. Carefully return HRESULT_FROM_WIN32
(ERROR_FILE_EXISTS) and HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) when
appropriate.

Your items will be queried for properties such as PKEY_FileName and
PKEY_DateModified in order to fill out the prompt dialog - or probably
whatever you define in PKEY_PropList_FileOperationPrompt.

The mistake I made when implementing this was actually to create the
FileOperation component with the FOF_NOCONFIRMATION flag when I needed
to paste files, which obviously supresses prompts! D'oh.

You can find my sample code here:
http://www.viksoe.dk/code/flickrdrive.htm


regards,
bjarke

Loading...