Save Image c#

Asked

Viewed 1,981 times

1

I’m having the following mistake Generic error of GDI+. when trying to save the image in a specific directory. I am using code below.

string caminho=@"\\\10.1.1.10\\sistema";
            Stream myStream = null;
        OpenFileDialog abrir = new OpenFileDialog();
        abrir.Filter = "Images (*.BMP;*.JPG;*.GIF,*.PNG,*.TIFF)|*.BMP;*.JPG;*.GIF;*.PNG;*.TIFF|" + "All files (*.*)|*.*";
        abrir.FilterIndex = 1;
        abrir.RestoreDirectory = true;
        if (abrir.ShowDialog() == DialogResult.OK)
        {
            if ((myStream = abrir.OpenFile()) != null)
                {
                   using (myStream)
                   {
                    Bitmap imagem = new Bitmap(abrir.FileName);//Pega o nome do arquivo escolhido
                    Bitmap igm = new Bitmap(imagem, 119, 110);//Padronisa o tamanho da imagaem ao picturebox
                    ImagemCamera.Image = igm;
                    ImagemCamera.Image.Save(caminho + "\\Fotos" + "\\" + Foto + "\\" + FotoId + ".Png", System.Drawing.Imaging.ImageFormat.Png);
                 }
       }

someone can help me?

1 answer

1


Well if you got here crazy for a reply. A few hours later I had the following conclusion. on the line where you save the picturebox, which in my case is named after Imagemcamera, would look like this

ImagemCamera.Image.Save(Path.GetFullPath(caminho) + "\\Fotos" + "\\" + Foto + "\\" + FotoId + ".Png", System.Drawing.Imaging.ImageFormat.Png);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.