Exemple #1
0
        private async void DownloadDBButton_Click(object sender, RoutedEventArgs e)
        {
            var download = await Data.DownloadDB();

            if (download == null)
            {
                return;
            }

            var savePicker = new FileSavePicker();

            savePicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
            savePicker.FileTypeChoices.Add(download.Type + " File", new List <string>()
            {
                download.Type
            });
            savePicker.SuggestedFileName = download.Name;

            StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null)
            {
                CachedFileManager.DeferUpdates(file);
                await FileIO.WriteBytesAsync(file, download.Data);

                FileUpdateStatus status =
                    await CachedFileManager.CompleteUpdatesAsync(file);

                if (status == FileUpdateStatus.Complete)
                {
                    //save
                }
                else
                {
                    // not saved
                }
            }
            else
            {
                //cancel
            }
        }