Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WPF application where there is an image control and when I click on it, an OpenFileDialog displays in order to choose an image from a file! now I want to save this image to a specific folder called working_folder

this is the location of the folder I want to save the image to:
C#
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\working_folder\\";

and the location of the image is this D:\Users\mowglin\Pictures\Images, and the image is type ".tif"
Please see the code below to make this more clear:
C#
bool imgLoaded = false;

            Image currentImg = (Image)sender;
            if (currentImg.Tag != null)
            imgLoaded = (bool)currentImg.Tag;
            if (!imgLoaded)
            {
                string filename = "";
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.DefaultExt = ".tif";
                dlg.Filter = "(*.tif,*.tiff)|*.tif;*.tiff";
                bool result = (bool)dlg.ShowDialog(this);
                if (result == true)
                {
                    filename = dlg.FileName;
                    currentImg.Source = new BitmapImage(new Uri(filename));
                    this.UpdateLayout();
                    currentImg.Tag = true;
                }
            }

so my question is, how can I save the image to a specefic directory?
Posted

1 solution

Try currentImg.Save(path,[what format you want to save]);

http://msdn.microsoft.com/en-us/library/9t4syfhh(v=vs.110).aspx[^]
 
Share this answer
 
Comments
Member 10920910 15-Jul-14 3:51am    
I tried currentImg.Save but it doesn't seem to work with WPF. Any other sulotion please?
ArunRajendra 15-Jul-14 4:16am    
Are you getting error? can you post the code you tried?

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