private async void MenuItem_Clicked(object sender, EventArgs e) { //delete File file = (sender as MenuItem).BindingContext as File; if (await DisplayAlert("U sure 'bout that?", "Do you really want to delete this " + file.FileType.ToString() + "?", "Yes", "No") == false) { return; } string response; if (file.FileType == FileType.File) { response = SendAndReceive("DELETE_FILE:" + file.FullName); } else { response = SendAndReceive("DELETE_FOLDER:" + file.FullName); } if (response != Codes.Success.ToString()) { await DisplayAlert("Exception ocurred", response.Remove(0, Codes.Error.ToString().Length), ControlPage.GetCancelButtonText()); } Update(); }
private void listView_ItemTapped(object sender, ItemTappedEventArgs e) { File file = e.Item as File; if (file.FileType == FileType.Folder) { directory = file.FullName; Update(); } else { FilePreviewPage page = new FilePreviewPage(file); Navigation.PushAsync(page); } }
private async void MenuItem_Clicked_2(object sender, EventArgs e) { //Download File file = (sender as MenuItem).BindingContext as File; if (file.FileType == FileType.File) { SendData("GET_FILE:" + file.FullName); byte[] bytes = ReceiveAvailableBytes(1); //System.IO.File.WriteAllBytes(localPath, bytes); ISaveFileInterface service = DependencyService.Get <ISaveFileInterface>(); service.SaveFile(file.Name, bytes); } else { DisplayAlert("sorry not sorry", "Sorry but you can't download entire folders yet.", "ree"); } }
private async void MenuItem_Clicked_1(object sender, EventArgs e) { //rename File file = (sender as MenuItem).BindingContext as File; string newName = await DisplayPromptAsync("Rename " + file.FileType.ToString(), "New name"); string response; if (file.FileType == FileType.File) { response = SendAndReceive("MOVE_FILE:" + file.FullName + "|" + GetFullName(directory, newName)); } else { response = SendAndReceive("MOVE_FOLDER:" + file.FullName + "|" + GetFullName(directory, newName)); } if (response != Codes.Success.ToString()) { await DisplayAlert("Exception ocurred", response.Remove(0, Codes.Error.ToString().Length), ControlPage.GetCancelButtonText()); } }