private async Task SendAFile() { if (sndr == null) { sndr = new OBEX_Sender(); } FileOpenPicker picker = null; #if IoTCore #else picker = new Windows.Storage.Pickers.FileOpenPicker(); #endif if (picker != null) { picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail; picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".txt"); Windows.Storage.StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { PostMessage("Picked textfile:", file.Name + "\r\nReady"); txt = await Windows.Storage.FileIO.ReadTextAsync(file); filename = file.Name; var t = Task.Run(async() => { await sndr.Send(txt, filename); }); PostMessage("Picker sending", file.Name); } else { PostMessage("PickAFile", "Operation cancelled."); } } else { await sndr.Send("Hello World", "Hi.txt"); PostMessage("Sent:", "Hi.Txt"); } if (sndr != null) { sndr.Dispose(); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { if (sndr != null) { sndr.Dispose(); sndr = null; } if (rcvr != null) { rcvr.Dispose(); rcvr = null; } Application.Current.Exit(); }