I keep getting an error that another process is using the file when I try to delete it. I know the process must be the for loop. How do I kill all processes.


PHP Code:
 Dim strJob As String
        strJob 
lv.SelectedItems(0).Text

        
'find the job and delete it
        Dim strFileName As String
        Dim strTempFile() As String
        Dim intUbound As Integer
        Dim strRemoveExtension As String


        For Each strFileName In Directory.GetFiles(strJobPath, "*.xml")
            strTempFile = Split(strFileName, "\")
            intUbound = UBound(strTempFile)
            strRemoveExtension = Microsoft.VisualBasic.Left(strTempFile(intUbound), Len(strTempFile(intUbound)) - 4)

            If strRemoveExtension.ToString.Equals(strJob) Then
                strFileToBeKilled = strFileName
            End If
        Next

        lv.SelectedItems(0).Remove()
        Kill(strFileToBeKilled)