I've been having problems with clearing a picture box. When a user clicks on the upload logo button the system copies whatever image file is selected by the user and copied into the repository. When the user clears the logo the image in the picture box removes the file from the repository and opens the default image. I am getting an exception error whenever I click on the clear logo button.
Private Sub cmdClearLogo_Click(sender As Object, e As EventArgs) Handles cmdClearLogo.Click
If strLogo IsNot "C:\Fowl\Images\Image Not Available.jpg" Then
picLogo.Image = Nothing
picLogo.Dispose()
My.Computer.FileSystem.DeleteFile(strLogo)
strLogo = "C:\Fowl\Images\Image Not Available.jpg"
picLogo.BackgroundImage = Image.FromFile(strLogo)
End If
End Sub
Private Sub cmdUploadLogo_Click(sender As Object, e As EventArgs) Handles cmdUploadLogo.Click
Dim strSource As String
My.Computer.FileSystem.CreateDirectory("C:\Fowl\Repository")
ofdLogo.ShowDialog()
If DialogResult.OK Then
strSource = ofdLogo.FileName
strLogo = "C:\Fowl\Repository\" + lblIDNO.Text + "l.jpg"
My.Computer.FileSystem.CopyFile(strSource, strLogo)
picLogo.BackgroundImage = Image.FromFile(strLogo)
End If
End Sub