I have a windows form application that I use to scan pdf and jpg documents. In the form I placed a webbrowser control to preview the scanned files.
All the file paths are displayed in a listbox and when the listindex change the webbrowser navigate to the file showing it.
Sometimes may happen that the scan isn't good or something like that so I need to delete the file, but when I select the file to delete it's opened in the webbrowser. I have no problem with jpeg, but with pdf it throws an exception telling that is impossible to delete the file because it's opened in another application.
I could kill the acrobat process but it's not the solution I want.
I tried to make the webbrowser navigate to about:blank and to dispose the webbrowser but with no luck.
Plus when I shut down the computer it always tells me that there is a document opened in acrobat and ask me if I want to close it. I think is related to my application.
Any help is appreciated
Private Sub cmsScanDeleteFile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmsScanDeleteFile.Click
Dim text As String = ""
Select Case lstScan.SelectedItems.Count
testo = "Are you sure you want to delete the selected file?"
Case Is > 1
testo = "Are you sure you want to delete " & lstScansioni.SelectedItems.Count & " selected files?"
Dim risp As String = MsgBox(text, MsgBoxStyle.YesNo)
If risp = vbYes Then
Dim cont As Integer = lstScan.SelectedItems.Count - 1
Dim drows(cont) As DataRowView
Dim x As Integer = 0
For Each dr As DataRowView In lstScan.SelectedItems
drows(x) = dr
x = x + 1
WebBrowser1.Url() = New Uri("about:blank")
For x = 0 To cont
Private Sub EliminaFile(ByVal id As Integer)
Dim rf As dsat.AttivazioniScansioniRow = Me.Dsat.AttivazioniScansioni.FindByid(id)
Dim file As String = ""
If rf.Locale = True Then
file = My.Settings.PercorsoLocaleAttivazioniWind & "\" & rf.NomeFile & rf.Estensione
file = My.Settings.PercorsoAttivazioni & "\" & rf.PercorsoRelativo & "\" & rf.NomeFile & rf.Estensione
Dim psi As New System.Diagnostics.ProcessStartInfo()
psi.UseShellExecute = True
psi.FileName = file
If System.IO.File.Exists(psi.FileName) = True Then
Dim risp As String = MsgBox("Il file non è stato trovato nel percorso corretto, vuoi eliminarlo anche dal programma?", MsgBoxStyle.YesNo)
If risp = vbYes Then