Click here to Skip to main content
11,803,019 members (48,701 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Access file Process
hi everyone

i would like some help with the application that we developed.
this is for our office use only, and what our app is doing is extracting the text from the pdf file using pdflibnet.dll

but we lately encountered a problem with a particular pdf file.
the problem is when we try to pdfdoc.load(strFileLocation) there is an error.
below is the sample code/function that we have so far.

And System.IO.File.Delete(TempFile) will stop the application from running.

"The process cannot access the file 'D:\temp\test2.pdf' because it is being used by another process."

i would like to attach the pdf file but here but there is no way for me to attch it here.

so here is the DL link from other fileservers.[^]

Public Function ExtractPDF(ByVal strl_File As String) As String
       Dim strl_RetVal As String = ""
       Dim TempFile As String = System.IO.Path.GetTempPath & Now.Ticks & ".txt"
       Dim pdfdoc As PDFLibNet.PDFWrapper = New PDFLibNet.PDFWrapper
       Dim pagecount As Integer = 0
           pagecount = pdfdoc.PageCount
             pdfdoc.ExportText(TempFile, 1, pagecount, True, True)
            If File.Exists(TempFile) Then
                strl_RetVal = System.IO.File.ReadAllText(TempFile)
            End If
            strl_RetVal = RemoveWhitespace(strl_RetVal) ' Remove white space
          Catch aveEx As System.AccessViolationException
            'release object from memory
        End Try
    Return strl_RetVal
    End Function
Posted 12-Jun-12 17:17pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 335
1 KrunalRohit 291
2 F-ES Sitecore 270
3 CPallini 270
4 Sergey Alexandrovich Kryukov 234
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,735
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 12 Jun 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100