private async void Upload_Executed() { this.IsBusy = true; try { if (string.IsNullOrEmpty(this.selectedName)) { throw new Exception("You forgot to enter a file name."); } // Connect to working folder await MyOneDrive.SetWorkingFolder(_WORKING_FOLDER_NAME); await MyOneDrive.SaveFile( MyOneDrive.WorkingFolder, this.selectedName, this.selectedContent.AsStream()); Toast.ShowInfo("Upload successful."); } catch (Exception ex) { Toast.ShowError(ex.Message); } finally { this.IsBusy = false; } }
private async void CreateAssets_Executed() { this.IsBusy = true; try { // Create Assets await MyOneDrive.SetWorkingFolder(_WORKING_FOLDER_NAME); for (int i = 1; i < 9; i++) { Debug.WriteLine("Creating file {0}", i); await MyOneDrive.SaveFile( MyOneDrive.WorkingFolder, string.Format("Sample file {0}.txt", i), string.Format("This is the content of sample file {0}", i).AsStream()); } } catch (Exception ex) { Toast.ShowError(ex.Message); } finally { this.IsBusy = false; } }
private async void Login_Executed() { this.IsBusy = true; try { // Login await MyOneDrive.Login(); } catch (Exception ex) { Toast.ShowError(ex.Message); } finally { this.IsBusy = false; } }
private async void Download_Executed() { this.IsBusy = true; try { var stream = await MyOneDrive.DownloadFile(this.SelectedFile); this.SelectedContent = stream.AsString(); } catch (Exception ex) { Toast.ShowError(ex.Message); } finally { this.IsBusy = false; } }
private async void Browse_Executed() { this.IsBusy = true; try { // Connect to working folder await MyOneDrive.SetWorkingFolder(_WORKING_FOLDER_NAME); // Get files this.Files = await MyOneDrive.GetFiles(MyOneDrive.WorkingFolder); } catch (Exception ex) { Toast.ShowError(ex.Message); } finally { this.IsBusy = false; } }
private async void ResetChanges_Executed() { this.IsBusy = true; try { // Connect to working folder await MyOneDrive.SetWorkingFolder(_WORKING_FOLDER_NAME); var changesResult = await MyOneDrive.ViewChanges(true); this.Changes = changesResult.Collection; } catch (Exception ex) { Toast.ShowError(ex.Message); } finally { this.IsBusy = false; } }
private async void Delete_Executed() { this.IsBusy = true; try { if (this.selectedFile == null) { throw new Exception("You forgot to select a file."); } await MyOneDrive.DeleteItem(this.SelectedFile); Toast.ShowInfo("Delete successful."); } catch (Exception ex) { Toast.ShowError(ex.Message); } finally { this.IsBusy = false; } }
private async void Logout_Executed() { // Logout await MyOneDrive.Logout(); }