Click here to Skip to main content
15,883,829 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
OpenFileDialog dlg = new OpenFileDialog();
 dlg.DefaultExt = "png";
  dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files(*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
           if (dlg.ShowDialog().Value)
            {
                // Open document
                string filename = dlg.FileName;
                //dlg1.Save();
                txtIdProofLocation.Text = filename;
               
             }




i have save button , when i click the save button selected image will store into the specified location
Posted
Updated 12-Feb-15 19:10pm
v3

As far as I understood, you want to select a file and then
save it to another location.

Selecting a file name for saving
can be achieved by using the SaveFileDialog.
I adapted your code:
C#
OpenFileDialog ofd = new OpenFileDialog();
SaveFileDialog sfd = new SaveFileDialog();

ofd.DefaultExt = "png";
ofd.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files(*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
if (ofd.ShowDialog().Value)
{
    if(sfd.ShowDialog().Value)
    {
        File.Copy(ofd.FileName, sfd.FileName);
    }               
}
 
Share this answer
 
v2
Comments
Richard MacCutchan 11-Feb-15 6:34am    
Better than my answer; +5.
TheRealSteveJudge 11-Feb-15 6:48am    
Thank you!
TheRealSteveJudge 11-Feb-15 7:02am    
Did you try the suggested solution?
At the moment I have no idea what you want to achieve.
[no name] 13-Feb-15 1:04am    
i tried it's worked bt my need is nt thank you for ur suggestion
TheRealSteveJudge 13-Feb-15 2:37am    
You're welcome!
Use a SaveFileDialog[^] to get the selected pathname, and write your file as required.
 
Share this answer
 
Comments
TheRealSteveJudge 11-Feb-15 6:24am    
Same idea! 5*
[no name] 11-Feb-15 6:29am    
i have save option, when i click then only save the file into another path.
thank you
Richard MacCutchan 11-Feb-15 6:33am    
Sorry but we cannot guess what that means. Please edit your question and show the code you are trying to use and explain exactly what happens.
[no name] 13-Feb-15 1:11am    
thank you for your effort

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