Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello People,

i'm developing a software which i can open images and it will give a preview of that image as well as you can save that image to c# project refferance folder by click another button called button

so basically i'm using openfiledialog for preview picture and browse.
but i don't need savefiledialog for save. because i just need to click the button and save it in the project folder, provide a message.

C#
private void BrwseBtn_Click(object sender, EventArgs e)
       {
           openFileDialog1 = new OpenFileDialog();

           openFileDialog1.InitialDirectory = "c:\\";
           openFileDialog1.Filter = "All files (*.*)|*.*";
           openFileDialog1.FilterIndex = 2;
           openFileDialog1.RestoreDirectory = true;

           if (openFileDialog1.ShowDialog() == DialogResult.OK)
           {
               try
               {
                   //PictureBox PictureBox1 = new PictureBox();
                   pictureBox1.Image = new Bitmap(openFileDialog1.FileName);
                   //file preview
                   this.Controls.Add(pictureBox1);
               }
               catch (Exception ex)
               {
                   MessageBox.Show("Error loading image" + ex.Message);
               }
           }
       }

private void UploadBtn_Click(object sender, EventArgs e)
        {
         // trying to save the file in C:\ drive
            string fileName = @"C:\\";

            this.UploadBtn.Image.Save(fileName);
            MessageBox.Show("Success");
            // let say i need to save not only image, i need to save images and docs as well
        }
Posted
Updated 12-Feb-15 0:07am
v2
Comments
Richard MacCutchan 12-Feb-15 6:53am    
You need to add some code to set the full pathname for the file, and then to actually write it. What exactly is the difficulty?
Hemas Ilearn 12-Feb-15 22:48pm    
Difficult thing is i cant save the the file on my project folder?
one button will open the image ? using openfiledialog.
to do the save i don't need savefiledialog?
i just need upload button click and just save that file on project folder? and give user message saying successful.
that's it

1 solution

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