Here is my code to save image in a folder,but i am getting this error(a generic error occurred in gdi+).
Could someone please help me?

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            If (Not System.IO.Directory.Exists("d:/posimage")) Then
                System.IO.Directory.CreateDirectory("d:/posimage")
            End If
    PictureBox1.Image.Save("d:/posimage")
    End sub

try this

Try
            Dim savefile As SaveFileDialog = New SaveFileDialog()
            savefile.DefaultExt = "jpeg"
            savefile.Filter = "All files*.*|*.*"
            If savefile.ShowDialog() = DialogResult.OK Then
                Int(Width = PictureBox1.Width)
                Int(Height = PictureBox1.Height)
                Dim Bitmap As Bitmap = New Bitmap(Width, Height)
                Dim rc As Rectangle = New Rectangle(0, 0, Width, Height)
                PictureBox1.DrawToBitmap(Bitmap, rc)
                Bitmap.Save(savefile.FileName,  System.Drawing.Imaging.ImageFormat.Jpeg)
            End If
        Catch ex As Exception
           msgbox(ex.tostring())
        End Try

Edited 4 Years Ago by Pgmer: n/a

thanks Pgmer.
I have used opendialog tool with a text box(to display path F:/Pictures/Tree.jpg) and a button(Open Folder)to open an image, and when i click on Submit button the image should move to a folder in D drive (D:/Image) and the new location(D:/Image/Tree.jpg) should be stored in database.Please help

Edited 4 Years Ago by prathapsv3: n/a

Then instead of using SaveFileDialog u can hard code the path u want to save and u need write a method or function whcih saves the pic into database. Use image datatype to save into DB

This article has been dead for over six months. Start a new discussion instead.