B
BobG
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
Dim position As Integer = lstImages.SelectedIndex
Try
Dim FileToDelete As String
FileToDelete = PicPath & "\" & lstImages.SelectedItem
Dim iResult As DialogResult _
= MessageBox.Show("Delete " & FileToDelete & "?", _
"Confirm Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Question)
If iResult = DialogResult.Yes Then
pbEditBox.Image.Dispose()
File.Delete(FileToDelete)
MsgBox("File Deleted!")
lstImages.Items.RemoveAt(position)
lstImages.Refresh()
lstImages.Focus()
End If
Catch ex As Exception
MsgBox("Error :" & ex.Source & " " & ex.Message)
Finally
Throw New System.Exception("An exception has occurred.")
End Try
The above routine does what it was intended to do that is:
pbEditBox Picturebox showing the image.
lstIamges Name of the listbox.
1. Delete an image file from its current location.
2. Remove its name from the listbox
But it also throws the following error
' ERROR: mscorlib Value cannot be null. parameter Nameath'
Does anyone know what is causing this error?
Thanks
System.EventArgs) Handles btnDelete.Click
Dim position As Integer = lstImages.SelectedIndex
Try
Dim FileToDelete As String
FileToDelete = PicPath & "\" & lstImages.SelectedItem
Dim iResult As DialogResult _
= MessageBox.Show("Delete " & FileToDelete & "?", _
"Confirm Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Question)
If iResult = DialogResult.Yes Then
pbEditBox.Image.Dispose()
File.Delete(FileToDelete)
MsgBox("File Deleted!")
lstImages.Items.RemoveAt(position)
lstImages.Refresh()
lstImages.Focus()
End If
Catch ex As Exception
MsgBox("Error :" & ex.Source & " " & ex.Message)
Finally
Throw New System.Exception("An exception has occurred.")
End Try
The above routine does what it was intended to do that is:
pbEditBox Picturebox showing the image.
lstIamges Name of the listbox.
1. Delete an image file from its current location.
2. Remove its name from the listbox
But it also throws the following error
' ERROR: mscorlib Value cannot be null. parameter Nameath'
Does anyone know what is causing this error?
Thanks