title: VB - cannot copy file due to "being used by another process" error
body: <p>I haven't been able to pinpoint exactly what is causing this error. All im trying to do is copy files (pdfs) that were created on the current day from 1 directory to another after a certain amount of time with the ticker. Here is my code:</p>
  
  <pre><code>Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  
      Dim file As String
      Dim now As String = DateTime.Today.ToShortDateString
      Dim dir As String = "C:\PDFs\"
      Dim bupdir As String = "C:\PDFs\copied\"
      Dim Files() As String = Directory.GetFiles(dir)
  
      For Each file In Files
          Dim dt As String = IO.File.GetLastWriteTime(file).ToShortDateString
          If dt = now Then
              IO.File.Copy(Path.Combine(dir, file), Path.Combine(bupdir, file), True)
          End If
      Next
  
  End Sub
  </code></pre>