title: The process cannot access the file because it is being used by another process
body: <p>I am adding images to a FlowLayoutPanel control via the following code</p>
  
  <pre><code>Dim WithEvents Pedit As DevExpress.XtraEditors.PictureEdit
  
  Private Sub LoadImagesCommon(ByVal fi As FileInfo)
          Pedit = New DevExpress.XtraEditors.PictureEdit
          Pedit.Width = 133
          Pedit.Height = 98
          Pedit.Image = Image.FromFile(fi.FullName)
          Pedit.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom
          Pedit.ToolTip = fi.Name
          AddHandler Pedit.MouseClick, AddressOf Pedit_MouseClick
          AddHandler Pedit.MouseEnter, AddressOf Pedit_MouseEnter
          AddHandler Pedit.MouseLeave, AddressOf Pedit_MouseLeave
          FlowLayoutPanel1.Controls.Add(Pedit)
      End Sub
  </code></pre>
  
  <p>The problem is that i get the following error <code>The process cannot access the file xxxx because it is being used by another process.</code> when i try to delete the images that i loaded on the previous step.</p>
  
  <pre><code>                    FlowLayoutPanel1.Controls.Clear()
                      FlowLayoutPanel1.Refresh()
                      For Each fi As FileInfo In New DirectoryInfo(My.Settings.TempDirectory).GetFiles
                          RemoveHandler Pedit.MouseClick, AddressOf Pedit_MouseClick
                          RemoveHandler Pedit.MouseEnter, AddressOf Pedit_MouseEnter
                          RemoveHandler Pedit.MouseLeave, AddressOf Pedit_MouseLeave
                          File.Delete(fi.FullName)
                      Next
  </code></pre>
  
  <p>So what am i doing wrong here?</p>