Take the 2-minute tour ×

I am new in wpf control and framework. I cant seem to save my images can you help me Below is my code

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.FileName = System.IO.Path.GetFileNameWithoutExtension(newlist[currentPicture]);                              
            Nullable<bool> result = sfd.ShowDialog();
            if (result == true)

                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(newlist[currentPicture]);
share|improve this question
That's not WPF. –  SLaks Dec 8 '10 at 1:13
You should accept answers to your questions. –  SLaks Dec 8 '10 at 1:14
Why not? What happens? –  SLaks Dec 8 '10 at 1:14
The three people coincidentally named @SLaks all make solid points. –  Dan J Dec 8 '10 at 1:17
@Slank i know the code i wrote is of windowForm but i cant seem to save my BitmapImage. Can you post a code that save a images placed in Wpf Image Control(using System.Windows.Media.Imaging.BitmapImage).. –  Pro_Zeck Dec 8 '10 at 1:34
add comment

1 Answer

For a System.Drawing.Bitmap, you need to pass the dialog's FileName property to the Save method.


var encoder = new PngBitmapEncoder()
using (var stream = dialog.OpenFile())
share|improve this answer
Slanks: Can you Explain whats does the last line do ? –  Pro_Zeck Dec 8 '10 at 2:03
@Pro: See the documentation. msdn.microsoft.com/en-us/library/… –  SLaks Dec 8 '10 at 2:04
add comment

Your Answer


