FIleSavePicker speichert 0 Bytye Datei Windows Phone 8

Also wurde mir jetzt gesagt, dass der FileSavePicker nur eine leere Datei erstellt und dass ich zusätzlichen Code schreiben muss, um dann tatsächlich in die Datei zu schreiben. Ich habe einen Task WriteToFile nach dem FileSavePicker gestartet, bin mir aber nicht sicher, wie ich ihn beenden soll. Mit dem FileSavePicker wählt der Benutzer den Ordner aus, in dem die Datei gespeichert werden soll. Wo weise ich im WriteToFile-Code darauf hin und wie genau füge ich die Dateiquelle darin ein? Die zu speichernden Dateien werden alle mit der App gepackt. Ich benutze hier x.mp3 als Beispiel.

    public class SoundData : ViewModelBase
    {
        public string Title { get; set; }
        public string FilePath { get; set; }



        public RelayCommand<string> SaveSoundAs { get; set; }

        private async void ExecuteSaveSoundAs(string soundPath)
        {

        string path = @"appdata:/x.mp3";
        StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
        StorageFile file = await folder.GetFileAsync(path);



                {
                    FileSavePicker savePicker = new FileSavePicker();
                    savePicker.SuggestedSaveFile = file;
                    savePicker.FileTypeChoices.Add("MP3", new List<string>() { ".mp3" });
                    savePicker.ContinuationData.Add("SourceSound", soundPath);
                    savePicker.SuggestedFileName = this.Title;
                    savePicker.PickSaveFileAndContinue();

                }

        }

        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            string soundPath = (string)args.ContinuationData["SourceSound"];
            StorageFile file = args.File;
            if (file != null)
            {
                // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
                CachedFileManager.DeferUpdates(file);
                // write to file



                await FileIO.WriteTextAsync(file, file.Name);
                // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);
                if (status == FileUpdateStatus.Complete) ;

            }
        }



        public SoundData()
        {
            SaveSoundAs = new RelayCommand<string>(ExecuteSaveSoundAs);
        }







    }
}

Antworten auf die Frage(1)

Ihre Antwort auf die Frage