Exemplo n.º 1
0
        private async void BtnOpenFile_OnClick(object sender, RoutedEventArgs e)
        {
            var openPicker = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".txt");

            var file = await openPicker.PickSingleFileAsync();


            if (file != null)
            {
                var content = await Windows.Storage.FileIO.ReadTextAsync(file);

                await GraphApiProxy.UploadNewFile(content, file.Name);
            }
            else
            {
                TxtFile.Text = "<select a file>";
            }
        }
Exemplo n.º 2
0
        private async void BtnDownloadFile_OnClick(object sender, RoutedEventArgs e)
        {
            using (var remoteStream = await GraphApiProxy.DownloadFile(TxtFileName.Text))
            {
                FileSavePicker picker = new FileSavePicker();

                picker.DefaultFileExtension = ".txt";
                picker.FileTypeChoices.Add("Text", new string[] { ".txt" });
                picker.FileTypeChoices.Add("Unknown", new List <string>()
                {
                    "."
                });
                picker.SuggestedFileName = TxtFileName.Text;
                var target = await picker.PickSaveFileAsync();

                var targetStream = await target.OpenStreamForWriteAsync();

                await remoteStream.CopyToAsync(targetStream);

                await targetStream.FlushAsync();
            }
        }
Exemplo n.º 3
0
 private async void BtnGetFiles_Click(object sender, RoutedEventArgs e)
 {
     var recent = await GraphApiProxy.GetRecentFiles();
 }