Error on deleting a file

The following code produces

"An unhandled exception of type 'System.IO.IOException' occurred in microsoft.visualbasic.dll

Additional information: The process cannot access the file "C:\Temp\Smith.pdf" because it is being used by another process."

The Code:

Dim form As Form = New Form("C:\Temp\ATemp.pdf", "C:\Temp\Smith.pdf")
Dim pdfv As New PdfViewer
form.FillField("Name", "Bob Smith")
form.Save()
pdfv.OpenPdfFile("C:\Temp\Smith.pdf")
Dim prs As New System.Drawing.Printing.PrinterSettings
Dim pgs As New System.Drawing.Printing.PageSettings
prs.Duplex = Duplex.Vertical
pgs.Margins.Bottom = 50
pgs.Margins.Top = 50
pgs.Margins.Left = 50
pgs.Margins.Right = 50
pgs.PaperSize = New System.Drawing.Printing.PaperSize("Custom", 800, 1050)
pdfv.PrintDocumentWithSettings(pgs, prs)
pdfv.ClosePdfFile()
Kill("C:\TempBIPDF\Smith.pdf")

The error occurs at the "Kill" line. Is there another way to close the file?

Thanks,

Jeff

Hi,

I think there is some mistake with the code you sent. I think the last statement should be

Kill("C:\Temp\Smith.pdf")

I was able to reproduce the error by making the above change. I have logged this as PDFKITNET-3830. Our developers will try their best to resolve this issue as soon as possible.

Thanks.