title: How to catch exception when attempting to delete a file in use?
body: <p>I't making a program to delete the files in my temp folder. I've gotten as far as the code to delete the files, But I can't seem to figure out how to skip the files in use or catch the exception so that my program doesn't crash when it attempts to delete a file in use.</p>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
          If CheckBox1.Checked = True Then
              Dim s As String
              For Each s In System.IO.Directory.GetFiles("C:\Users\" + System.Environment.UserName + "\AppData\Local\Temp")
                  System.IO.File.Delete(s)
              Next s
          End If
  end sub
  </code></pre>