I am getting error when I tried to save image from PictureBox
Saying "generic error occurred in GDI+", that was appear when a file already exist. but working if file not already exist. It can't override the image inside the folder. How can trap that to override the image. Thanks.
Here is my code
Code:Private Sub opneIMG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opneIMG.Click Dim openFD As New OpenFileDialog Dim clientImg As New PictureBox Dim img As Bitmap With openFD .Title = "Select Picture of Client" & lvClients.Items(lvClients.FocusedItem.Index).SubItems(1).Text .DefaultExt = "*.jpg" .Filter = "*.jpg | *.jpg" .InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures .Multiselect = False .ShowDialog() img = Bitmap.FromFile(.FileName) End With Dim bmp As Bitmap = New Bitmap(img, 150, 150) Dim grp As Graphics = Graphics.FromImage(bmp) clientImg.Image = bmp clientImg.Image.Save(Application.StartupPath & "\PROFILES\" & IDtoSearch & "\" & IDtoSearch & ".jpeg", Imaging.ImageFormat.Jpeg) End Sub




Reply With Quote