首页 > 解决方案 > 如何选择多个文件 C# UWP?

问题描述

我正在构建一个音乐应用程序,需要允许用户选择多个文件。我已经使用 PickMultipleFilesAsync() 尝试了 FileOpenPicker,但它因意外错误而崩溃。

浏览 C# 文档没有成功。

var openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync(); // <- crashes here

标签: c#

解决方案


给它 filetypefilter 然后再试一次

openpicker.FileTypeFilter.Add(".csv"); //add the type of of file you are going to select for example ".csv"

否则,从这个小片段来看,一切似乎都很好。


推荐阅读