Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am working on winForm and want to save product image in database. How can i do this? i have added I have added
1. dev express pictureEdit control
2. A button with Text Browse with follwing code
C#
 using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Title = "Open Image";
                dlg.Filter = "All Files|*.*"; 

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    //PictureBox Picture = new PictureBox();
                    pictureEdit1.Image = new Bitmap(dlg.FileName);
}

3. savedialog box
4. open dialog box
And i don't want save in database i just want to save it a floder of my solution
i have checked on web one solution found with file upload but in Winform Fileupload control not available
Posted

1 solution

C#
//build save to folder path using application path
string saveToPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "FileFolder");
//combine path with original file name and build full path
string saveToFullPath= Path.Combine(saveToPath, Path.GetFileName(dlg.FileName));
//copy file to folder
System.IO.File.Copy(dlg.FileName, saveToFullPath);
 
Share this answer
 

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