The process cannot access the file because it is being used by another process

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF PrintManager for .NET (v2.x)  /  Display Thread

DynamicPDF PrintManager for .NET (v2.x) Forum

After I print pdf:
PrintJob printJob = new PrintJob(printerName, filepath);

I call:
File.Move(filepath, archiveFilePath);

It give me the following error:
"The process cannot access the file because it is being used by another process."

Any help?

Posted by a ceTe Software moderator

Here is a sample code that shows how to use a PDF and dispose it after printing. Disposing the InputPdf after the call to Print() method will release the file handle on the actual file. 

        // Create a print job
        PrintJob printJob = new PrintJob("PrinterName");

        // Create an InputPdf object to hold the source PDF
        InputPdf inputPdf = new InputPdf(@"C:\MyDocument.pdf", "password");

        // Add the InputPdf's pages to the print job

        // Print the job

       // Dispose InputPDF

ceTe Software Support Team.
 Aug 31 2017 9:11 AM
Hi, I am getting this error while printing pdf file.
please help me.

ceTe.DynamicPDF.Printing.PrintFailedException: An error occurred while printing the document's pages. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at a(e* , Void* , Int32 , Int32 , Int32 , Int32 , Int32 , Int32 )
   at ceTe.DynamicPDF.Printing.InputPdf.a(e* , Void* , Int32 , Int32 , Int32 , Int32 , Int32 , Int32 , Boolean )
   at ceTe.DynamicPDF.Printing.ActualSizePageScaling.a(PrintJobPage , Int32 , Int32 )
   at ceTe.DynamicPDF.Printing.ActualSizePageScaling.z(PrintJobPage )
   at ceTe.DynamicPDF.Printing.PrintJobPage.i()
   at ceTe.DynamicPDF.Printing.PrintJobPageList.a()
   at ceTe.DynamicPDF.Printing.PrintJob.Print()
   --- End of inner exception stack trace ---
   at ceTe.DynamicPDF.Printing.PrintJob.Print()
Posted by a ceTe Software moderator

Can you please send over the following details to so we can look into it further?

1. Sample code without dependencies that we can run on our end to recreate the issue.
2. Does the error happen with specific PDF(s)? If yes, please provide some sample PDFs.
3. Exact version and build number of the DynamicPDF PrintManager for .NET product DLL file. You can get this information in DLL references properties (Version field) in Visual Studio.
4. Operating system details: Name, x86 or x64.
5. Does the error happen when printing to specific printer(s)?.If you have not tried then please try printing to some other printer and let us know the results.
6. Are you printing to a network printer using a UNC path \\servername\\printername or a locally installed printer?
7. Printer details: Name, exact version of the printer driver.
8. Full error message along with stack trace.

ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 8:26 AM.