Printing fails and the existing file is deleted

Symptoms

Consider the following scenario:
  • You print out to a file by specifying an existing file to overwrite it.
  • Another application (e.g. Reader app) is opening the file as a memory-mapped file.
In this scenario, printing operation fails with the following error message:
Invalid handle.
Additonally, the specified existing file is deleted.

Cause

This problem may occur because of the behavior of StartDocPrinter API where an application calls to print out. The API tries to open the file exclusively first and if it fails then tries to delete it.

Resolution

Retry to print out when the problem occurs.

Workaround

To avoid this problem, specify a non-existent new file as an output file when printing.
Properties

Article ID: 3181521 - Last Review: Aug 25, 2016 - Revision: 1

Feedback