WebBrowser Control Locks Files
- From: John R. Dougherty <JohnRDougherty@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 10 Dec 2006 23:08:01 -0800
I am using the WebBrowser control in a VB6 project (ieframe.dll), and it is
apparently causing a lock on .PDF files when I use the control to display a
..PDF document.
Here is the line of code I am using to display .PDF documents:
webImage.Navigate2 strDocToView
The basic premise of my application is that the user will view the .PDF
document, key in some data entry items about the document, then the document
is copied to another location, and the original document is deleted.
The problem occurs in that, on some machines, not all, when the delete is
executed, the VB app throws an error - permission denied. I put some code in
to attempt doing the delete several times, but again on some PCs, it
continues to fail doing the delete. I then added some code to allow the user
to choose to delete the original file by answering a MsgBox question, and
this does allow the file to be deleted. Here is the section of code doing
all of this:
If Dir$(strFileToDelete) <> "" Then
'== trap "permission denied" error when trying to delete the
unprocessed document; we had problems with the WebImage control apparently
keeping a lock on the file, and so the delete was rejected
On Error Resume Next
blnResult = False
y = 0
Do While blnResult = False
Me.MousePointer = vbHourglass
Do While blnResult = False And y < 5000
If Dir$(strFileToDelete) <> "" Then
Kill strFileToDelete
If Err.Number <> 0 Then
y = y + 1
Else
blnResult = True
End If
Else
blnResult = True
End If
Loop
Me.MousePointer = vbNormal
If blnResult = False Then
y = 0
If MsgBox("Unable to delete " & strFileToDelete & "." &
vbCrLf & vbCrLf & "Ready to try again?", vbYesNo, App.ProductName & " -
Deleting Unprocessed Documents") = vbNo Then
blnResult = True
MsgBox strFileToDelete & " must be deleted manually so
that it will not end up getting processed again later.", vbInformation,
App.ProductName & " - Deleting Unprocessed Documents"
End If
End If
Loop
End If
The users of my application do not like having to stop to answer the MsgBox
Yes/No question. How can I resolve this issue? Should I be using something
other than the WebBrowser control?
And I also added this code, in order to try to point the WebBrowser to an
"empty" location in order to turn loose of the .PDF file:
If UCase$(gstrFileExt) = ".PDF" Then
webImage.Navigate2 "_"
End If
- Thanks,
JRD
.
- Prev by Date: Re: Sending e-mail through VB Button
- Next by Date: How do I stop the WebBrowser control evaluating special characters?
- Previous by thread: Re: Sending e-mail through VB Button
- Next by thread: How do I stop the WebBrowser control evaluating special characters?
- Index(es):