C# .NET - how to browse and save the image in folder?

Asked By chitra ganapathy on 08-Dec-12 12:48 AM
hi, i want to browse the image and display in picture box and the image should save in one folder, which may be in C: or D: drive, i used the following coding for browse and displaying in picture box

OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
            if (open.ShowDialog() == DialogResult.OK)
                Image img = new Bitmap(open.FileName);
                string imagename = open.SafeFileName;
                Txt_countrylogo.Text = imagename;
                pictureBox2.Image = img.GetThumbnailImage(340, 165, null, new IntPtr());
                open.RestoreDirectory = true;
now i need the help for saving the image in folder, Please suggest some idea.
Jatin Prajapati replied to chitra ganapathy on 10-Dec-12 08:15 AM
Hi Chitra,
This is very simple.

private void button1_Click(object sender, EventArgs e)
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                Image img = new Bitmap(openFileDialog1.FileName);
                string fileName = openFileDialog1.FileName;
                pictureBox1.Image = img.GetThumbnailImage(340, 165, null, new IntPtr());
                img.Save(@"C:\uploadedfiles\" + System.IO.Path.GetFileName(openFileDialog1.FileName));
chitra ganapathy replied to Jatin Prajapati on 11-Dec-12 12:12 AM
Thank you so much