pvginkel / PdfiumViewer

PDF viewer based on Google's PDFium.
Apache License 2.0
967 stars 418 forks source link

File unload #64

Closed Ravindran001 closed 8 years ago

Ravindran001 commented 8 years ago

How to unload the pdf file, while delete the file after showing pdf, File access error occur. I am Dispose function also used. it not worked.

pvginkel commented 8 years ago

This should just work. Could you possibly provide a code sample that demonstrates the problem?

On Tue, May 3, 2016, 16:24 Ravindran001 notifications@github.com wrote:

How to unload the pdf file, while delete the file after showing pdf, File access error occur. I am Dispose function also used. it not worked.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/pvginkel/PdfiumViewer/issues/64

Ravindran001 commented 8 years ago

Sample code:

PDFviewer1.Document = PdfiumViewer.PdfDocument.Load(FileName) {

Some codes...

}

if File.exist(FileName) then File.Delete(FileName) End if

Error Shows: The process cannot access the file 'File Path' because it is being used by another process.

pvginkel commented 8 years ago

What I'm missing is the Dispose call of PDFviewer1.Document. You do need to dispose that before you can delete the file.

On Wed, May 4, 2016 at 11:45 AM Ravindran001 notifications@github.com wrote:

Sample code:

PDFviewer1.Document = PdfiumViewer.PdfDocument.Load(FileName) { Some codes...

}

if File.exist(FileName) then File.Delete(FileName) End if

Error Shows: The process cannot access the file 'File Path' because it is being used by another process.

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/pvginkel/PdfiumViewer/issues/64#issuecomment-216813817

Ravindran001 commented 8 years ago

I tried with dispose call but the error exist the same

PDFviewer1.Document = PdfiumViewer.PdfDocument.Load(FileName) { Some codes...

} PDFviewer1.Dispose() 'using dispose call if File.exist(FileName) then File.Delete(FileName) End if

Error Shows: The process cannot access the file 'File Path' because it is being used by another process.

pvginkel commented 8 years ago

The stream was not correctly disposed. This should have been solved. I'm creating a new version in a moment. Please let me know if that didn't solve your issue.