Click here to Skip to main content
15,902,892 members
Please Sign up or sign in to vote.
3.50/5 (4 votes)
See more:
In my application i upload photo of employee using OpenFileDialog and display photo in picture box. i want photo should be store in local system for example in "E:\" drive.below is my code of photo upload.

C#
private void btnphotoupload_Click(object sender, EventArgs e)
        {
            // upload image and display in picture box

            OpenFileDialog open = new OpenFileDialog();
            // image filters
            open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
            if (open.ShowDialog() == DialogResult.OK)
            {
                // display image in picture box
                pictureBox1.Image = new Bitmap(open.FileName);

                // image file path
                // textBox1.Text = open.FileName;

            }
           // var = open.FileName;
            Data.imagelocation = open.FileName;
           

        }
Posted
Comments
Vishal Sharma 20-Jul-13 13:13pm    
Bro what is Data here in Data.imagelocation = open.FileName;

Not really sure what your issue is but SaveFileDialog could be used:
http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx#Y2964[^]
and saving the picture:
http://msdn.microsoft.com/en-us/library/9t4syfhh.aspx[^]
 
Share this answer
 
See this:
C#
private void button1_Click(object sender, EventArgs e)
{
   pictureBox1.Image.Save("C:\\Temp\\Test.bmp");
}
 
Share this answer
 
Comments
Espen Harlinn 11-Sep-12 10:19am    
5'ed!
Hi,

try this,

C#
private void btnphotoupload_Click(object sender, EventArgs e)
    {
        // upload image and display in picture box

        OpenFileDialog open = new OpenFileDialog();
        // image filters
        open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
        if (open.ShowDialog() == DialogResult.OK)
        {
            BitMap btMap = new Bitmap(open.FileName);

            // display image in picture box
            pictureBox1.Image = btMap;
            
           //Save the image in new location
           btMap.Save(@"E:\Images\Image.jgp");
            
        }
       // var = open.FileName;
        Data.imagelocation = open.FileName;
    }


Hope it works
 
Share this answer
 
Comments
Vishal Sharma 20-Jul-13 13:28pm    
what is Data here
Karthik Harve 22-Jul-13 6:26am    
OP is using that. OP can answer to your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900