Anatole

Anatole

  • NA
  • 8
  • 13.4k

image being used problem

Jun 30 2010 2:07 PM
Hello
I'm making a deleter program, but it has a preview window to double check the picture before you want to delete it. I made it so that the picture changes before the program deletes it, but I get an error: cannot delete so and so picture because it is being used by another process.
Here is my code:
   Dim strFileName As String


        If boogooo = "N" Then


            Dim DidWork As Integer = openFD.ShowDialog()
            If DidWork <> DialogResult.Cancel Then
                strFileName = openFD.FileName
                PictureBox1.Image = Image.FromFile(strFileName)
                Label2.Text = strFileName
                TextBox2.Text = strFileName
            End If
        Else


            Dim DidWork As Integer = openFD.ShowDialog()
            If DidWork <> DialogResult.Cancel Then
                strFileName = openFD.FileName

                TextBox2.Text = strFileName

            End If
        End If

Private Sub one()
        PictureBox1.Image = Image.FromFile("C:/Program Files/Filemover/Icon4.ico")


        System.Threading.Thread.Sleep(1000)
        Label2.Text = "No image is being previewed"
        System.Threading.Thread.Sleep(1000)
        Call deleter()


        FileToDelete = openFD.FileName

If System.IO.File.Exists(FileToDelete) = True Then

System.IO.File.Delete(FileToDelete)
MsgBox("File Deleted")

End If


      
    End Sub
    Private Sub deleter()

       

    End Sub