Search code examples
c#windows-store-appswindows-store

Windows 8 store image inside local storage


Now when I save the image it will prompt out FileSavePicker. Can I programmatically save the image in local storage instead call the FileSavePicker. Please help Thanks.

   FileSavePicker savePicker = new FileSavePicker();
    savePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;

    savePicker.FileTypeChoices.Add("PNG image", new List<string>() { ".png" });

    if (sourceFile == null)
    {
        this.Frame.Navigate(typeof(GroupedItemsPage));
    }

    savePicker.SuggestedFileName = "CroppedImage";
    StorageFile cropfile = await savePicker.PickSaveFileAsync();

    cropAndSaveImage(cropfile);

Solution

  • Yes. I would recommend reading the entire page here, because it covers most of the common variations you'll want to consider. In particular you will probably be interested in the ApplicationData.LocalFolder and the application data sample.

    The solution will still involve getting a StorageFile at some point, of course, so it wouldn't be difficult to fit into the code you provided. Instead of opening a picker, you use CreateFileAsync method on a StorageFolder you get by using ApplicationData.LocalFolder (or one of the variations).