Beispiel #1
0
        private async void RestoreBackupCommandHandler(object obj)
        {
            try
            {
                var fop = new FileOpenPicker();
                // Add supported file types
                fop.FileTypeFilter.Add(".kdf");

                // Pick file to open and read
                var result = await fop.PickSingleFileAsync();

                if (result != null)
                {
                    var fs = await result.OpenReadAsync();

                    string profileData;
                    // Create a stream reader
                    using (var sr = new StreamReader(fs.AsStreamForRead()))
                    {
                        profileData = await sr.ReadToEndAsync();
                    }

                    // Upload the profile data
                    var resp = await KryptPadApi.UploadProfile(profileData);

                    await DialogHelper.ShowMessageDialogAsync(ResourceHelper.GetString("ProfileRestored"));

                    await GetProfilesAsync();
                }
            }
            catch (WebException ex)
            {
                // Something went wrong in the api
                await DialogHelper.ShowMessageDialogAsync(ex.Message);
            }
            catch (Exception ex)
            {
                // Failed
                await DialogHelper.ShowGenericErrorDialogAsync(ex);
            }
        }