Hello, I am using the evaluation version of the pdf converter v2.5 (Developer). My program allows the user to cancel a print job before the pdf file is fully created. I must delete the half-created pdf file, so in my abort procedure I use the following code:
m_pDC->AbortDoc();
pApp->DisablePDFPrinter();
if (! DeleteFile(pApp->m_strPDFFileName))
AfxMessageBox("Clean up failed");
(m_pDC and pApp are simply pointers to the Device Context and the App respectively)
I consistently get an error (code = 32 - Sharing Violation - "The process cannot access the file because it is being used by another process") when trying to delete the file.
However, stepping through the code in debug successfully deletes the file without error! Does the Amyuni printer hold on to the last file for a short period of time even after calling DisablePDFPrinter(); ? This would explain the fact that it works in a very slow environment (debug) but not in normal running mode.
Any thoughts or advice will be much appreciated.
Sharing Violation when deleting pdf file after cancelling
Thanks Joan.
I have used an AfxMessageBox between the call to AbortDoc() and the call to DeleteFile() to tell the user that their file will be deleted. The user's delay in pressing 'OK' gives the spooler enough time to release the file before I come to deleting it.
Not an ideal solution, and it might not work on all systems, but it is extremely rare for our users to cancel a job anyway.
Regards,
John
I have used an AfxMessageBox between the call to AbortDoc() and the call to DeleteFile() to tell the user that their file will be deleted. The user's delay in pressing 'OK' gives the spooler enough time to release the file before I come to deleting it.
Not an ideal solution, and it might not work on all systems, but it is extremely rare for our users to cancel a job anyway.
Regards,
John