Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF files on a webbrowser object

Status
Not open for further replies.

tmar

MIS
Mar 24, 2007
62
US
I've got a simple document viewing program that lists a group of files in a folder (mostly PDF's) and when the user clicks on a file in the list it shows on a webbrowser object.

I want to put in a utility to delete the file but I keep getting an error message (only on the PDF files) that "the file is in use". I tried both the file.delete("filename") and my.computer.filesystem.deletefile("filename") and get the same result. I even tried disposing the webbrowser object before the attempt to delete the file and it still resulted in the "object in use" error.

Below is the code.

Me.wbDoc.Url = Nothing
Me.wbDoc.Dispose()

If Me.lstFiles.Items.Count > 0 Then
Dim filename As String = Me.lstFiles.SelectedItem


Try
My.Computer.FileSystem.DeleteFile(filename)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
loadfiles()
Else : End If
 

It's probably the PDF viewer loaded within the browser not releasing the file even though you close the brower window.




Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top