title: How do I delay a vb.net program until a file operation completes?
body: <p>I have this:</p>
  
  <pre><code>    Dim myTemp As String
      myTemp = System.DateTime.Now().ToString("MMMddyyyy_HHmmss") &amp; ".pdf"
  
      System.IO.File.Copy(myFile, "c:\" &amp; myTemp)
      Application.DoEvents()
      OpenFile(myTemp)
  </code></pre>
  
  <p>The problem is that when I call OpenFile, which is just a call to a sub that opens a file, it cannot find the file.  This is because it is calling it so quickly that the program doesn't have time to actually create the file before the open takes place.</p>
  
  <p>I thought that DoEvents() would rectify this but it does not.  I need to wait until the file is created before I open the file.  How can I do that?</p>