public async Task DeleteAsync(ISftpFile fileToDelete) { var confirmationDialog = new MessageDialog("Are you sure?"); confirmationDialog.Commands.Add(new UICommand("Yes", null, true)); confirmationDialog.Commands.Add(new UICommand("No", null, false)); var confirmation = await confirmationDialog.ShowAsync(); if (!(bool)confirmation.Id) { return; } var dialog = default(MessageDialog); try { await fileToDelete.DeleteAsync(); this.Files.Remove(fileToDelete); } catch (Exception exp) { Debug.WriteLine(exp); dialog = new MessageDialog("Something went wrong, please try again in a bit."); } if (dialog != null) { await dialog.ShowAsync(); } }
public async Task DownloadAsync(ISftpFile fileToDownload) { var fileSavePicker = new FileSavePicker(); fileSavePicker.SuggestedStartLocation = PickerLocationId.Downloads; fileSavePicker.FileTypeChoices.Add("Any file type", new List <string>() { "." }); fileSavePicker.SuggestedFileName = fileToDownload.Name; var fileToSave = await fileSavePicker.PickSaveFileAsync(); if (fileToSave == null) { return; } var startNotification = NotificationHelper.Factory("Download started", string.Format("The file {0} has started downloading...", fileToDownload.Name), fileToDownload.ImagePath); ToastNotificationManager.CreateToastNotifier().Show(startNotification); try { using (var targetStream = await fileToSave.OpenStreamForWriteAsync()) { var download = fileToDownload.DownloadAsyncWithProgress(targetStream); download.Progress = (info, progress) => { fileToDownload.Progress = progress / (double)fileToDownload.Size; }; await download; } var successNotification = NotificationHelper.Factory("Download finished", string.Format("The file {0} was downloaded successfully.", fileToDownload.Name), fileToDownload.ImagePath); ToastNotificationManager.CreateToastNotifier().Show(successNotification); } catch (Exception exp) { Debug.WriteLine(exp); var errorNotification = NotificationHelper.Factory("Download failed", string.Format("The file {0} could not be downloaded.", fileToDownload.Name), fileToDownload.ImagePath); ToastNotificationManager.CreateToastNotifier().Show(errorNotification); } }
public async Task DeleteAsync(ISftpFile fileToDelete) { }
public async Task DownloadAsync(ISftpFile fileToDownload) { }