当前位置: 首页>>代码示例>>C#>>正文


C# FileOpenPicker.PickMultipleFilesAsync方法代码示例

本文整理汇总了C#中Windows.Storage.Pickers.FileOpenPicker.PickMultipleFilesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# FileOpenPicker.PickMultipleFilesAsync方法的具体用法?C# FileOpenPicker.PickMultipleFilesAsync怎么用?C# FileOpenPicker.PickMultipleFilesAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Storage.Pickers.FileOpenPicker的用法示例。


在下文中一共展示了FileOpenPicker.PickMultipleFilesAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddButtonClick_OnClick

        private async void AddButtonClick_OnClick(object sender, RoutedEventArgs e)
        {
            var picker = new FileOpenPicker();
            picker.FileTypeFilter.Add(".jpg");
            var files = await picker.PickMultipleFilesAsync();

            TreeMap.Children.Clear();

            var sources = new List<BitmapImage>();
            foreach (var file in files)
            {
                var stream = (await file.OpenStreamForReadAsync()).AsRandomAccessStream();//await file.GetScaledImageAsThumbnailAsync(ThumbnailMode.PicturesView, 300);
                var imageSource = new BitmapImage();
                await imageSource.SetSourceAsync(stream);

                sources.Add(imageSource);

                var image = new Image();
                image.Stretch = Stretch.UniformToFill;
                image.Source = imageSource;
                TreeMap.Children.Add(image);
            }

            MosaicImage.Source = sources;
        }
开发者ID:nguyenkien,项目名称:MosaicImageControls,代码行数:25,代码来源:MainPage.xaml.cs

示例2: CopyButton_Click

        async void CopyButton_Click(object sender, RoutedEventArgs e)
        {
            OutputText.Text = "Storage Items: ";
            var filePicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.List,
                FileTypeFilter = { "*" }
            };

            var storageItems = await filePicker.PickMultipleFilesAsync();
            if (storageItems.Count > 0)
            {
                OutputText.Text += storageItems.Count + " file(s) are copied into clipboard";
                var dataPackage = new DataPackage();
                dataPackage.SetStorageItems(storageItems);

                // Request a copy operation from targets that support different file operations, like File Explorer
                dataPackage.RequestedOperation = DataPackageOperation.Copy;
                try
                {
                    Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
                }
                catch (Exception ex)
                {
                    // Copying data to Clipboard can potentially fail - for example, if another application is holding Clipboard open
                    rootPage.NotifyUser("Error copying content to Clipboard: " + ex.Message + ". Try again", NotifyType.ErrorMessage);
                }
            }
            else
            {
                OutputText.Text += "No file was selected.";
            }
        }
开发者ID:mbin,项目名称:Win81App,代码行数:33,代码来源:CopyFile.xaml.cs

示例3: SelectFilesButton_Click

        private async void SelectFilesButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker filePicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.List,
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
                FileTypeFilter = { "*" }
            };

            IReadOnlyList<StorageFile> pickedFiles = await filePicker.PickMultipleFilesAsync();

            if (pickedFiles.Count > 0)
            {
                this.storageItems = pickedFiles;

                // Display the file names in the UI.
                string selectedFiles = String.Empty;
                for (int index = 0; index < pickedFiles.Count; index++)
                {
                    selectedFiles += pickedFiles[index].Name;

                    if (index != (pickedFiles.Count - 1))
                    {
                        selectedFiles += ", ";
                    }
                }
                this.rootPage.NotifyUser("Picked files: " + selectedFiles + ".", NotifyType.StatusMessage);

                ShareStep.Visibility = Visibility.Visible;
            }
        }
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:31,代码来源:ShareFiles.xaml.cs

示例4: ImportEPubAsync

        public static async Task<bool> ImportEPubAsync()
        {
            try
            {
                var ePubPicker = new FileOpenPicker();
                ePubPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                ePubPicker.FileTypeFilter.Add(".epub");

                var files = await ePubPicker.PickMultipleFilesAsync();

                if (files.Count > 0)
                {
                    var ePubDirectory = await ApplicationData.Current.RoamingFolder.GetFolderAsync("ePubs");

                    foreach (var file in files)
                    {
                        var fileDirectory = await ePubDirectory.CreateFolderAsync($"{file.DisplayName}.{DateTime.Now.ToFileTime()}");
                        var copiedFile = await file.CopyAsync(fileDirectory);
                        await Task.Run(() => ZipFile.ExtractToDirectory(copiedFile.Path, fileDirectory.Path));
                    }
                }

                return true;
            }

            catch
            {
                return false;
            }
        }
开发者ID:RareNCool,项目名称:EPubReader,代码行数:30,代码来源:ImportController.cs

示例5: Button_Click_1

        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;

            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");
            
            IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();

            foreach(var file in files)
            {
                var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                BitmapImage image = new BitmapImage();
                image.SetSource(stream);

                ImageData data = new ImageData();
                data.image = image;
                data.name = file.DisplayName;

                this._list.Add(data);
            }
        }
开发者ID:coelacanth77,项目名称:MultiFilePickerSample,代码行数:26,代码来源:MainPage.xaml.cs

示例6: OpenFileButtonOnTapped

        private async void OpenFileButtonOnTapped(object sender, TappedRoutedEventArgs e)
        {
            var filePicker = new FileOpenPicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary };
            filePicker.FileTypeFilter.Add("*");

	        var files = await filePicker.PickMultipleFilesAsync();
			if (files == null || files.Count == 0) return;

			foreach (var file in files)
	        {
		        try
		        {
					var storeStream = await file.OpenAsync(FileAccessMode.Read);
					var dicomFile = DicomFile.Open(storeStream.AsStream());
			        var fileImage = new DicomFileImage(Path.GetFileNameWithoutExtension(file.Path), file, dicomFile);

			        var modality = fileImage.Modality;
			        var modalityGroup = _modalityGroups.FirstOrDefault(m => m.Modality.Equals(modality));
					if (modalityGroup == null)
					{
						_modalityGroups.Add(new ModalityGroup { Modality = modality, FileImages = new ObservableCollection<DicomFileImage> { fileImage }});
					}
					else
					{
						modalityGroup.FileImages.Add(fileImage);
					}
		        }
		        catch
		        {
		        }
	        }

		}
开发者ID:1danielcoelho,项目名称:FellowOakDicomTesting,代码行数:33,代码来源:MainPage.xaml.cs

示例7: btnFilePicker_Click

        private async void btnFilePicker_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add("*");
            IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();
            if (files != null && files.Count > 0)
            {
                string output = "";

                foreach (StorageFile file in files)
                {
                    output += file.Name + Environment.NewLine;
                }
                tbPickedFiles.Text = output;

                if (this.noteFileList != null)
                {
                    this.noteFileList.AddRange(files);
                }
                else
                {
                    this.noteFileList = new List<StorageFile>();
                    this.noteFileList.AddRange(files);
                }
            }
            else
            {
                tbPickedFiles.Text = "";
            }
        }
开发者ID:gulyu,项目名称:SmartNote,代码行数:32,代码来源:MainPage.xaml.cs

示例8: BrowseForImages

        private async void BrowseForImages()
        {            
            StatusText = "Running...";
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.CommitButtonText = "Open";
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpe");
            openPicker.FileTypeFilter.Add(".bmp");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".gif");
            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();

            if (files.Count > 0)
            {
                ResultsList.Clear();
            }
            foreach (StorageFile file in files)
            {
                try
                {
                    var result = await ProcessImage(file);
                    ResultsList.Add(result);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
            StatusText = "Ready";
        }
开发者ID:pingzing,项目名称:SimpleOcr10,代码行数:32,代码来源:MainPageViewModel.cs

示例9: PickFilesButton_Click

        private async void PickFilesButton_Click(object sender, RoutedEventArgs e)
        {
            // Clear any previously returned files between iterations of this scenario
            OutputTextBlock.Text = "";

            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add("*");
            IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();
            if (files.Count > 0)
            {
                StringBuilder output = new StringBuilder("Picked files:\n");
                // Application now has read/write access to the picked file(s)
                foreach (StorageFile file in files)
                {
                    output.Append(file.Name + "\n");
                }
                OutputTextBlock.Text = output.ToString();
            }
            else
            {
                OutputTextBlock.Text = "Operation cancelled.";
            }
        }
开发者ID:RasmusTG,项目名称:Windows-universal-samples,代码行数:25,代码来源:Scenario2_MultiFile.xaml.cs

示例10: Add_OnClick

        private async void Add_OnClick(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;
            var tool = (string)btn.Content;

            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".gif");

            var storageFiles = await openPicker.PickMultipleFilesAsync();
            if (storageFiles == null)
            {
                await new MessageDialog("请选择图片").ShowAsync();
                return;
            }

            this.progressRing.IsActive = true;

            byte[] content = null;

            // 获取指定的文件的文本内容

            var count = 0;
            foreach (var storageFile in storageFiles)
            {
                IRandomAccessStreamWithContentType accessStream = await storageFile.OpenReadAsync();

                var fileName = storageFile.Name;

                using (Stream stream = accessStream.AsStreamForRead((int)accessStream.Size))
                {
                    content = new byte[stream.Length];
                    await stream.ReadAsync(content, 0, (int)stream.Length);
                }

                var fileData = new List<KeyValuePair<string, byte[]>>();
                fileData.Add(new KeyValuePair<string, byte[]>(fileName, content));


                var repository = new RepositoryAsync();
                var users = await repository.GetRandomUsers(1);

                var user = users.FirstOrDefault();

                var api = new UArticleService();

                var result = await api.CreateUArticle(user.UserId, user.SessionId, "testtitle", "", tool, fileData);
                if (result.Success)
                {
                    count++;
                }
            }

            this.progressRing.IsActive = false;

            await new MessageDialog($"{count}个乐图成功创建").ShowAsync();
        }
开发者ID:BiaoLiu,项目名称:YLP.UWP.TOOLS,代码行数:59,代码来源:AddUArticlePage.xaml.cs

示例11: UploadBackgroundAmazon

 public async Task UploadBackgroundAmazon()
 {
     FileOpenPicker openPicker = new FileOpenPicker();
     openPicker.ViewMode = PickerViewMode.Thumbnail;
     openPicker.FileTypeFilter.Add("*");
     IReadOnlyList<StorageFile> file = await openPicker.PickMultipleFilesAsync();
     if(file!=null)
         await AmazonUploadFile(file);
 }
开发者ID:prashanthganathe,项目名称:PersonalProjects,代码行数:9,代码来源:AudienceInfo.xaml.cs

示例12: PickMultipleFilesAsync

async public void PickMultipleFilesAsync()
{
    FileOpenPicker picker = new FileOpenPicker();
    picker.FileTypeFilter.Add(".png");
    picker.FileTypeFilter.Add(".jpg");
    picker.FileTypeFilter.Add(".gif");
    picker.FileTypeFilter.Add(".bmp");
    picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
    picker.ViewMode = PickerViewMode.Thumbnail;
    IReadOnlyList<StorageFile> files = await picker.PickMultipleFilesAsync();
}
开发者ID:BeyondVincent,项目名称:WindowsStoreAppCode,代码行数:11,代码来源:MainPage.xaml.cs

示例13: MultipleFilePicker_Click

 private async void MultipleFilePicker_Click(object sender, RoutedEventArgs e)
 {
     FileOpenPicker picker = new FileOpenPicker();
     picker.FileTypeFilter.Add(".png");
     picker.FileTypeFilter.Add(".jpg");
     picker.FileTypeFilter.Add(".gif");
     picker.FileTypeFilter.Add(".bmp");
     picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
     picker.ViewMode = PickerViewMode.Thumbnail;
     IReadOnlyList<StorageFile> files = await picker.PickMultipleFilesAsync();
 }
开发者ID:Jxperez,项目名称:31DaysOfWindows8,代码行数:11,代码来源:MainPage.xaml.cs

示例14: OpenFiles

 //select files to play through a play picker
 private async void OpenFiles()
 {
     FileOpenPicker fileOpenPicker = new FileOpenPicker();
     // Filter to include a sample subset of file types
     fileOpenPicker.FileTypeFilter.Add(".mp3");
     fileOpenPicker.FileTypeFilter.Add(".wma");
     fileOpenPicker.FileTypeFilter.Add(".flac");
     fileOpenPicker.FileTypeFilter.Add(".m4a");
     fileOpenPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
     IReadOnlyList<StorageFile> files = await fileOpenPicker.PickMultipleFilesAsync();
     //add files to playlist
     if (files.Count != 0)
             await AcceptFiles(files);
 }
开发者ID:MichaelAi,项目名称:Aural-Player,代码行数:15,代码来源:MainViewModel.cs

示例15: PickMultipleFilesAsync

		/// <summary>
		/// Opens a file picker and allows the user to pick multiple files and return a list of the files the user chose
		/// </summary>
		/// <param name="location"></param>
		/// <param name="filterTypes"></param>
		/// <returns></returns>
		public async Task<IReadOnlyList<StorageFile>> PickMultipleFilesAsync(
			PickerLocationId location = PickerLocationId.DocumentsLibrary, params string[] filterTypes)
		{
			FileOpenPicker openPicker = new FileOpenPicker();

			openPicker.SuggestedStartLocation = location;

			if (filterTypes != null)
			{
				foreach (string filterType in filterTypes)
				{
					openPicker.FileTypeFilter.Add(filterType);
				}
			}

			return await openPicker.PickMultipleFilesAsync();
		}
开发者ID:karolszmaj,项目名称:StyleMVVM,代码行数:23,代码来源:FilePickerService.cs


注:本文中的Windows.Storage.Pickers.FileOpenPicker.PickMultipleFilesAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。