Articles in this section
Category / Section

How to change the image saving location in UWP?

2 mins read

By default, in SfImageEditor when we save image, the image will be getting saved in gallery. We can also able to change the image saving location.


Step 1: Create SfImageEditor sample with all necessary assemblies.


Please refer the below link to create a simple SfImageEditor sample along with the ways to configure it.


Step 2: Get stream from ImageSaving event. Create method for selecting folders and pass the stream as argument


Step 3: Convert the stream to bitmap and save image in custom location.


The following code snippet illustrates the way to this method,




public sealed partial class MainPage : Page
        public MainPage()
            BitmapImage bitmapImage = new BitmapImage();
            Uri uri = new Uri("ms-appx:///Assets/Image.jpg");
            bitmapImage.UriSource = uri;
            imageeditor.ImageSource = bitmapImage;
            imageeditor.ImageSaving -= Imageeditor_ImageSaving;
            imageeditor.ImageSaving += Imageeditor_ImageSaving;
        Stream stream;
        private void Imageeditor_ImageSaving(object sender, ImageSavingEventArgs args)
            args.Cancel = true;
            stream = args.Stream;
        public async void SelectDirectory(Stream stream)
   = stream;
            IRandomAccessStream randomAccessStream =;
            var wbm = new WriteableBitmap(600, 800);
            await wbm.SetSourceAsync(randomAccessStream);
            string fileName = "image.jpg";
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();
            folderPicker.SuggestedStartLocation = 
            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();
            string SelectedFolderPath = folder.Path;
            if (folder != null)
                // Application now has read/write access to all contents in the picked folder
                // (including other sub-folder contents)
                FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                StorageFile file = await folder.CreateFileAsync(fileName, 
                using (var storageStream = await file.OpenAsync(FileAccessMode.ReadWrite))
                    var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, storageStream);
                    var pixelStream = wbm.PixelBuffer.AsStream();
                    var pixels = new byte[pixelStream.Length];
                    await pixelStream.ReadAsync(pixels, 0, pixels.Length);
                    encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)wbm.PixelWidth, (uint)wbm.PixelHeight, 200, 200, pixels);
                    await encoder.FlushAsync();




Sample link:



Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Please sign in to leave a comment