0

How to copy *.png from appdata:/assets/images using FileSavePicker. I find this example File Save Picker - Save Edited Image (C# Metro app) but it does not work.

i have this code:

private async void OpenButton_Click(object sender, RoutedEventArgs e)
    {

        string path = @"\Assets\Logo.png";
        StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
        StorageFile file = await folder.GetFileAsync(path);

        // Show the picker
        FileSavePicker savePicker = new FileSavePicker();
        // Set the file that will be saved
        savePicker.SuggestedSaveFile = file;
        savePicker.SuggestedFileName = "Logo";
        savePicker.FileTypeChoices.Add("PNG", new List<string>() { ".png" });
        savePicker.PickSaveFileAndContinue();



    }

but he saves the file to 0 bytes

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

0

Did you try out the sample from msdn? Where did you go wrong withe one you found?

FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Plain Text", new List<string>() { ".txt" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "New Document";

Source:

Community
  • 1
  • 1
Kulasangar
  • 9,046
  • 5
  • 51
  • 82